• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java date/calender help needed

 
nand rai
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • 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.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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.
 
Rob Spoor
Sheriff
Pie
Posts: 20493
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic