• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to compare the datetime to find the latest datatime  RSS feed

 
Mike Boota
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an xml payload with multiple fields for date-time. The datetime is populated as below:

2007-04-06T10:46:47.411-05:04
2007-04-06T10:46:47.410+02:01
2007-04-06T10:46:47.411-03:00
2007-04-06T10:46:47.411+09:03
2007-04-06T10:46:47.411-09:03

Now how do I find out which is the latest datetime. Any help is appreciated.

Thanks
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, those look like ISO 8601 formats. you should be able to parse them easily with a SimpleDateFormat. The Java Tutorial is a good place to learn how this works.

EXCEPT...

The last part of those times makes no sense. For example "-05:04" indicates that the time was recorded in a time zone whose offset was 5 hours and four minutes behind Greenwich Mean Time. The fact that all but one of the time zone offsets are nonzero is deeply suspicious. In the real world, time zone offsets mostly have the minutes set to 0. Some have 30 or 45. Here's a list. But the fact that the numbers shown here are 4, 1, 3... that makes me think that whoever recorded these times did not do so correctly.

Perhaps someone made up some numbers as examples of the format, without fully understanding them? That's fine. But if this is supposed to be "real" data, I think it's highly probable that it's defective, and this can probably only be fixed by understanding how the times were recorded in the first place, and what format did they think they were using.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!