(reposted from http://pastie.org/954797)
I'm looking to convert a unix epoch time to Iso8601. I made the
following method which has worked on my G1 phone for a long time:
public static String DateTimeIso8601(long offset) {
DateFormat datePattern = new SimpleDateFormat ("yyyy-
MM-dd'T'HH:mm:ssZ");
datePattern.setTimeZone(TimeZone.getTimeZone("GMT"));
String date = datePattern.format(new Date(offset));
return date;
}
output is the UTC time with an erroneous timezone (got -0800 but
should be -0000 or Z).
log("date test: "+Util.DateTimeIso8601(1273546315000L));
Output from adb logcat: date test: 2010-05-11T02:51:55-0800
As a sanity test, a ruby language script with same int converted to
time:
irb(main):002:0> Time.at(1273546315)
=> 2010-05-10 19:51:55 -0700
irb(main):003:0> Time.at(1273546315).utc
=> 2010-05-11 02:51:55 UTC
is this an Android 2.1 problem?
The same code on my android 1.6 G1 phone returns the UTC time zone
D/GeoRSS ( 381): date test: 2010-05-11T02:51:55+0000
Don
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en