• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

How to compare the datetime to find the latest datatime

 
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
 
Wanderer
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.
 
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic