0

I am getting time in milliseconds ("1369807669") format from JSON and i have to change that in "yyyy-MM-dd'T'HH:mm:ssS" format ... How can i do it??

I used this code but i am getting different time not the actual time.

SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
df.setTimeZone(TimeZone.getTimeZone("GMT"));
DateTime = df.format(millis);

But i am getting time as "1970-12-23'T'12:54:32+0000" which is wrong...

I should get time something like this "2013-05-29'T'12:06:53+0000"

Saad
  • 309
  • 2
  • 9
  • 21

2 Answers2

3

you have seconds not milliseconds you should multipy your seconds * 1000

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
0

check this for your current date and check with your json milliseconds also

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

          df.setTimeZone(TimeZone.getTimeZone("GMT"));
        String currentDate = formatter.format(new Date(System
                .currentTimeMillis())));

may be you are getting wrong time in json

anddevmanu
  • 1,459
  • 14
  • 19