I am using Facebook graph API to retrieve user wall information. In that, I am getting the post created time value as:
created_time: "2012-04-19T09:00:02+0000"
Can anyone suggest me how to convert this time to UTC or epoch value in Java?
The format of date you receive is ISO 8601.
As described in Converting ISO8601-compliant String to java.util.Date (using Joda-Time):
DateTimeFormatter parser = ISODateTimeFormat.dateTimeNoMillis();
String jtdate = "2012-04-19T09:00:02+0000";
System.out.println(parser.parseDateTime(jtdate));
You basically need to parse the ISO8601 date format. There are libraries out there that would do it for you or you can create your own parser (relatively simply), e.g.
http://www.java2s.com/Code/Java/Data-Type/ISO8601dateparsingutility.htm
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