I have a string like the following "2010-02-15T20:05:28.000Z" and I need to output the string in GMT format using Java.
BTW, I have no idea what format the date is currently in.
This format is xml-schema, You can convert like this:
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
String dateStr = "2010-02-15T20:05:28.000Z";
try {
Date date = format.parse(dateStr);
System.out.println(date.toGMTString());
} catch (ParseException e) {
e.printStackTrace();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With