aspose file tools*
The moose likes Java in General and the fly likes Analizing Dates for Calculation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Analizing Dates for Calculation" Watch "Analizing Dates for Calculation" New topic
Author

Analizing Dates for Calculation

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
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

Sue Temple
Greenhorn

Joined: May 01, 2010
Posts: 19
Add a printline to your catch block and you will see what went wrong -

Replace:


with:
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
Sue Temple wrote:Add a printline to your catch block and you will see what went wrong -

Replace:


with:


Thanks, works great now.
 
Don't get me started about those stupid light bulbs.
 
subject: Analizing Dates for Calculation