• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Analizing Dates for Calculation

 
Ranch Hand
Posts: 2206
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using the following to see if a datetime is before current datetime but it seems that my checkdate is only reading the date porition

Console output

CheckD: 2010-05-24 08:09:08.655872
CT: Mon May 24 12:42:24 CDT 2010
KT: Mon May 24 13:42:24 CDT 2010
LF: 0

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add a printline to your catch block and you will see what went wrong -

Replace:


with:
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A ParseException happens but you don't notice, because you are swallowing the exception in lines 12-14.

Note that the format you specified to parse the date "dd/MM/yyyy HH:mm:ss" doesn't match what you put in: "2010-05-24 08:09:08.655872"

Don't ever swallow exceptions like that, at least print an error message.
 
Steve Dyke
Ranch Hand
Posts: 2206
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sue Temple wrote:Add a printline to your catch block and you will see what went wrong -

Replace:


with:



Thanks, works great now.
 
reply
    Bookmark Topic Watch Topic
  • New Topic