jQuery in Action, 2nd edition*
The moose likes Java in General and the fly likes Java date/calender help needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
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: 6109
    
    6

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

Joined: Jan 03, 2004
Posts: 6109
    
    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: 6109
    
    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: 19651
    
  18

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java date/calender help needed
 
Similar Threads
first date and last date of month
Help with select statements
Java quarterly calculation
Where to check version
Best time to land in USA for H1-B job seekers