• 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

How to get yesterday's business date

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"?
 
Ranch Hand
Posts: 64
Netbeans IDE Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic