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 Getting Last Date of Previous Month Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Getting Last Date of Previous Month " Watch "Getting Last Date of Previous Month " New topic

Getting Last Date of Previous Month

ShivPrakash Srivastava
Ranch Hand

Joined: Mar 24, 2005
Posts: 88

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
Paul Sturrock

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:
subject: Getting Last Date of Previous Month
Similar Threads
first date and last date of month
date problem in linux
the date of the last day of month
Date for last month
getting first and last date of past 6 months?