File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Date problems - Strings and math Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Date problems - Strings and math" Watch "Date problems - Strings and math" New topic
Author

Date problems - Strings and math

clive vh
Greenhorn

Joined: Sep 28, 2001
Posts: 6
Good day all
I'm using the Sun JDK1.3.0_02 on Windows 2000. I need to:
1) get the current date in the format dd/mm/yyyy (call this the deal_date)
2) add 30 days to the above (call the result expiry_date)
3) convert both deal_date and expiry_date to Strings
4) when calling expiry_date from a database, compare it to the current (system) date to see if the difference is greater than 30 days.
Please could somone give me the cleanest possible method of doing this. I have grappled with the classes Calendar, GregorianCalendar, Date and DateFormat until my head hurts. I would prefer to use the standard classes found in the JDK rather than adding additional classes.
many thanks.
Clive
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Clive,
Try the following code. It might be what you are looking for.

Enjoy,
Manfred.
clive vh
Greenhorn

Joined: Sep 28, 2001
Posts: 6
Thanks very much Manfred, this is just fine. Thanks also to JavaRanch for a really useful site
Clive
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Date problems - Strings and math
 
Similar Threads
Weird Problem in using Commons Digester - Any pointers??
optimation of resources plz help
how to add 30 days to current data?
Happy Birthday(?) to me!!!
Dates as String