This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes How to grab current date??? 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 » Other JSE/JEE APIs
Reply locked New topic

How to grab current date???

Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
I have used some calender usage etc(using some ones posting from the web)
Following is my code:
Calendar dateCreated = Calendar.getInstance(new Locale("en","US"));
SimpleDateFormat df = new SimpleDateFormat("yyyy");
// apply the format object to the calendar object.
String formattedDate = df.format(dateCreated.getTime());

But it is giving me bad date.
Can some body suggest some thing easier.

SCJP, blog
Rob Ross

Joined: Jan 07, 2002
Posts: 2205
you have already posted this exact same question here
Please post your question only one time and in one forum. Many people read multiple forums and it wastes time and space to have to keep track of multiple answers in different threads.

SCJP 1.4
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: How to grab current date???
Similar Threads
Format Date using Calendar
How to get tomorrow's date?
How to grab current date