aspose file tools*
The moose likes Java in General and the fly likes How to get yesterday's business date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to get yesterday Watch "How to get yesterday New topic
Author

How to get yesterday's business date

nancy andrew
Ranch Hand

Joined: Jan 19, 2010
Posts: 30
I am writing a program which gets todays date and yesterday's date. The dates should be business dates. If today is Tuesday then it should furnish yesterday's date which was a Monday. But if today is Monday then it should furnish yesterday's date which was a friday. How to write this program in java. Also the dates which i want should be in Eastern standard time. I dont want GMT. Please help me.

Regards,
Nancy
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
Sounds like: create a Calendar object, subtract a day from it, check if it's on a weekend and if so, subtract 1 or 2 days from it depending on whether it's a Saturday or Sunday. The Calendar class has all the methods you'd need for this, and it can handle timezones.

Would you need to consider official holidays as "non-business days"?
Jacob Anawalt
Ranch Hand

Joined: Oct 27, 2010
Posts: 32

If you want something more robust, and especially if you need holidays, consider a library like Objectlab kit. I've been happy with it and Joda.


Jacob
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get yesterday's business date
 
Similar Threads
Getting yesterday's date ......
scw.js calender widget
Date in java
af:selectInputDate error with JBoss/Tomcat
want to get day