my dog learned polymorphism*
The moose likes Java in General and the fly likes Getting Last Date of Previous Month Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Getting Last Date of Previous Month " Watch "Getting Last Date of Previous Month " New topic
Author

Getting Last Date of Previous Month

ShivPrakash Srivastava
Ranch Hand

Joined: Mar 24, 2005
Posts: 88
Hi,

How can I get the last date of the previous month in java ? For example if the date entered is 1/4/2007,the I should get the output as 31/3/2007.Code snippet for this would really help.

Thanks and Regards
Shiv
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Code snippet for this would really help

Well, in the big picture its going to help you less (see this)

Have a look at the Calendar class and notice that there are methods to rollback a calender by a particular amount for a particular field (minute, hour, day, year etc.). Also notice there are methods to get the maximum value a particular field can hold.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting Last Date of Previous Month