Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java - How to convert this string to date?

I am receiving this from the server and I don´t understand what the T and Z means, 2012-08-24T09:59:59Z What's the correct SimpleDateFormat pattern to convert this string to a Date object?

like image 592
Héctor Júdez Sapena Avatar asked Jul 29 '26 13:07

Héctor Júdez Sapena


2 Answers

This is ISO 8601 Standard. You may use

SimpleDateFormat simpleFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");

to convert this.

like image 170
Chathuranga Chandrasekara Avatar answered Jul 31 '26 04:07

Chathuranga Chandrasekara


This is the ISO datetime format, see here, T is the time separator and Z is the zone designator for the zero UTC offset.

There is a very similar, if not identical question here, see it to know how to convert this string to a Java DateTime object.

like image 41
Curious Avatar answered Jul 31 '26 04:07

Curious



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!