Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Facebook JSON created_time of String format to long format

I'm working on android app and trying to get created_time from facebook JSON. I was successful in that and I got it as 2011-07-14T12:28:52+0000 .

Now this should be converted into long format like 220200202932093

My challenge now is to convert that into long format.

This is because i have planned to get relative time using getRelativeTimeSpanString in android.

Please help me to convert String formatted time from JSON object to long format

like image 694
shanmugam Avatar asked Dec 10 '22 07:12

shanmugam


1 Answers

String exampleDateString = "2011-07-14T12:28:52+0000";
try 
{
    long timeMillis = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss+SSSS")
        .parse(exampleDateString)
        .getTime();
} catch (Exception e) {
    e.printStackTrace();
}
like image 141
scessor Avatar answered Mar 16 '23 00:03

scessor