Skip to content

Instantly share code, notes, and snippets.

@bdkosher
Created March 1, 2016 02:16
Show Gist options
  • Select an option

  • Save bdkosher/e8f28b23c7267e08e7af to your computer and use it in GitHub Desktop.

Select an option

Save bdkosher/e8f28b23c7267e08e7af to your computer and use it in GitHub Desktop.
Using XMLGregorianCalendar to format dates.
import javax.xml.datatype.*
def c = DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar())
c.setDay(1)
c.setMonth(1)
c.setYear(2016)
c.setTime(0,0,0,0)
c.setTimezone(0)
assert '2016-01-01T00:00:00.000Z' == c.toXMLFormat()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment