Did you actually try passing 2007-02-16T18:41:41.296+0530 to the
Utility.parseDateTime() method? I don't know of any problems in this
area, though it's always possible you've discovered something new.
If you're able to make SimpleDateFormat work for you that's great. I
didn't say it couldn't be done, only that I didn't see exactly how to do
it in a way I trusted to always work properly. You are likely to still
run into problem using SimpleDateFormat if anyone tries using a date
prior to the Julian/Gregorian conversion, but that's probably not a
major concern for most people. :-) However, I'd think that at a minimum
you'd need to always set the timezone to UTC (technically the correct
choice for schema, not GMT).
- Dennis
Dennis M. Sosnoski
SOA and Web Services in Java
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117
Amila Suriarachchi wrote:
hi dennis,
I checked your parseDateTime method.
It seems that it does not works for the values like
2007-02-16T18:41:41.296+0530. But as I understood the spec allow this
type of date formates as well. As I understood your method only
supports GMT time zone values.
Lets take this piece of code.
try {
// using jibx utility
System.out.println("date value 1171631501296 ==> " +
Utility.parseDateTime("2007-02-16T18:41:41.296"));
System.out.println("date value 1171631501296 ==> " +
Utility.parseDateTime("2007-02-16T13:11:41.296Z"));
// using simple Date formatter class
SimpleDateFormat simpleDateFormat1 = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm: ss.SSS");
SimpleDateFormat simpleDateFormat2 = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
SimpleDateFormat simpleDateFormat3 = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm: ss.SSS'Z'");
simpleDateFormat3.setTimeZone(TimeZone.getTimeZone("GMT"));
System.out.println("date value 1171631501296 ==> " +
simpleDateFormat1.parse("2007-02-16T18:41: 41.296").getTime());
System.out.println("date value 1171631501296 ==> " +
simpleDateFormat2.parse("2007-02-16T18:41:41.296+0530").getTime());
System.out.println("date value 1171631501296 ==> " +
simpleDateFormat3.parse("2007-02-16T13:11:41.296Z").getTime());
} catch (Exception e) {
e.printStackTrace(); //To change body of catch statement
use File | Settings | File Templates.
}
here 2007-02-16T18:41:41.296+0530 and 2007-02-16T13:11:41.296Z are
basically same values equal to 1171631501296. In your method since it
only supports GMT times first instance give a wrong value ( reason is
no way to give any other time zone)
So using SimpleDateFormatter class ADB supports this form as well.
On the other hand your parseDateTime method should have written in an
easy way with SimpleDateFormatter.
SimpleDateFormat simpleDateFormat3 = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm: ss.SSS'Z'");
simpleDateFormat3.setTimeZone(TimeZone.getTimeZone("GMT"));
return simpleDateFormat3.parse("2007-02-16T13:11:41.296Z").getTime();
--
Amila Suriarachchi,
WSO2 Inc.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]