Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting "2010-02-15T20:05:28.000Z" in GMT format using Java [closed]

Tags:

java

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.

like image 665
kimbaudi Avatar asked Mar 24 '26 12:03

kimbaudi


1 Answers

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();
}
like image 76
P.C.DING Avatar answered Mar 26 '26 03:03

P.C.DING



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!