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.

Reply via email to