I need to convert a java.util.Date variable to a representation similar to the one below.
1995-12-31T23:59:59.999Z
The format for this date field is of the form 1995-12-31T23:59:59Z, and is a more restricted form of the canonical representation of dateTime http://www.w3.org/TR/xmlschema-2/#dateTime.
The trailing “Z” designates UTC time and is mandatory.
You can use
SimpleDateFormat.Output:
Here you’re manually setting the time zone on the date formatter to UTC.