This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Java date/calender help needed Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Java date/calender help needed" Watch "Java date/calender help needed" New topic
Author

Java date/calender help needed

nand rai
Greenhorn

Joined: Feb 17, 2009
Posts: 27
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

Joined: Jan 03, 2004
Posts: 5888
    
    6

Look at Calendar and its add() method.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 5888
    
    6

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

Joined: Feb 17, 2009
Posts: 27
I have updated the question.

Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 5888
    
    6

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

Joined: Oct 27, 2005
Posts: 19216

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?


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Java date/calender help needed
 
Similar Threads
Best time to land in USA for H1-B job seekers
Java quarterly calculation
Where to check version
Help with select statements
first date and last date of month