Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert String timestamp with offset to Java date

Tags:

java

timestamp

I need to convert this timestamp string to a Java Date object

2014-04-03T14:02:57.182+0200

How do I do this? How do I handle the time offset included in the timestamp

like image 268
user906153 Avatar asked Sep 27 '26 12:09

user906153


1 Answers

You can use this code:

String strdate = "2014-04-03T14:02:57.182+0200";
Date date = new SimpleDateFormat("yyyy-mm-dd'T'HH:mm:ss.SSSZ").parse(strdate);
System.out.println(date);
like image 171
djm.im Avatar answered Sep 29 '26 03:09

djm.im



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!