• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Java date/calender help needed

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have situation where I need to calculate the dates as follows

today
yesterday
last week
last Quarter
quarter to date

how do i achieve this .

say for example if today's date is 12/21/2011
i want to get "Yesterday" as 12/20/2011( this is simple) using calender class

how to achieve the last WEEK and last Quarter?

Thanks In Advance.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at Calendar and its add() method.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, TellTheDetails. It's impossible to know what you've tried and what specific problems you had if you don't tell us.
 
nand rai
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have updated the question.

 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

nand rai wrote:I have updated the question.



That really doesn't provide any new information. My first reply still stands. Try it, and if you're still stuck, post back with your attempt and details about what's you're having trouble with.
 
Sheriff
Posts: 22857
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

nand rai wrote:I have updated the question.


Please don't do that. Whatever changes you make to existing posts may cause any reply to look ridiculous. Just create a new post with the updated information.

Now, define "last week". Is it exactly 7 days ago? Is it the first day of the week? Or what?
Likewise for "last quarter". Would that be July 1st, October 31st, or what?
 
reply
    Bookmark Topic Watch Topic
  • New Topic