wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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: 1393
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: 14074
    
  16

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 7 API documentation
Scala Notes - My blog about Scala
Steve Dyke
Ranch Hand

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

Replace:


with:


Thanks, works great now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Analizing Dates for Calculation
 
Similar Threads
java.util.Date
Incrementing Date By 6 Months
Generating a Start and Finish Date
date
Something about current time