File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes java calneder example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic

java calneder example

nand rai

Joined: Feb 17, 2009
Posts: 27
I have situation where I need to calculate the dates as follows

last week
last Quarter

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 12/11/2011 to 12/17/2011

And as far as Last quarter concerned

Q1 - January, February, and March
Q2 - April, May, and June
Q3 - July, August, and September
Q4 - October, November, December

if today's date is 12/21/2011

then last quarter would be Q3 07/01/2011 to 09/30/2011.

How do i achieve this with java date or calender class or by any other means.

Thanks In Advance.
endswel shui
Ranch Hand

Joined: Jul 03, 2008
Posts: 33
Caculate the 'days' of every month for the year

just use Calendar.add(-days)
Joanne Neal

Joined: Aug 05, 2005
Posts: 3742
You've already asked this question here

I agree. Here's the link:
subject: java calneder example
It's not a secret anymore!