what is T in the date in java 1

what is T in the date in java

The T is just a literal to separate the date from the time, and the Z means "zero hour offset" also known as "Zulu time" (UTC). If your strings always have a "Z" you can use: SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss. SSS'Z'", Locale.US); format. setTimeZone(TimeZone.07-Dec-2011

Here is what the above code is Doing:
1. We create a new SimpleDateFormat object with the format string “yyyy-MM-dd’T’HH:mm:ss.SSS’Z'”.
2. We set the time zone to UTC.
3. We parse the string into a Date object.
4. We create a new SimpleDateFormat object with the format string “yyyy-MM-dd HH:mm:ss”.
5. We format the Date object into a String.
6. We print the String.

The output is:
2011-12-07 15:42:07

Similar Posts