| Author |
How to compare the datetime to find the latest datatime
|
Mike Boota
Ranch Hand
Joined: Jul 18, 2002
Posts: 82
|
|
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
|
MB<br />Sun Certified Programmer for Java2 Platform
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
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.
|
"I'm not back." - Bill Harding, Twister
|
 |
 |
|
|
subject: How to compare the datetime to find the latest datatime
|
|
|