Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

How to compare the datetime to find the latest datatime

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I hired a bunch of ninjas. The fridge is empty, but I can't find them to tell them the mission.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic