This week's book giveaway is in the
General Computing
forum.
We're giving away four copies of
Arduino in Action
and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
How to format a date.
Anthony Smith
Ranch Hand
Joined: Sep 10, 2001
Posts: 285
posted
Aug 08, 2005 09:30:00
0
I have a Date object.
I want to print the date like this:
20050808
I use:
Calendar c = Calendar.getInstance();
c.setTime(shipDate1); //shipDate is my Date Objecy
String
date = String.valueOf(c.get(Calendar.YEAR)) + String.valueOf(c.get(Calendar.DAY_OF_MONTH)) +
String.valueOf((Calendar.DAY_OF_MONTH));
The 0's from the day and month keep getting trimmed. There has to be a clean way to do this.
Richard Anderson
Ranch Hand
Joined: May 20, 2005
Posts: 61
posted
Aug 08, 2005 09:45:00
0
There is a clean way to do this.
Take a look at
SimpleDateFormat
-Rich, SCJP 1.4
I agree. Here's the link:
http://aspose.com/file-tools
subject: How to format a date.
Similar Threads
Date Function - HOLIDAY
How to read a file
Calendar returns wrong date?
Time refreshing
Calender class and its components
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter