Two Laptop Bag*
The moose likes Beginning Java and the fly likes Creating a String from DateTime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Creating a String from DateTime" Watch "Creating a String from DateTime" New topic
Author

Creating a String from DateTime

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1439
    
    1
I need to generate a 14 character string from the current DateTime. I will use this as an index for new created records. I need it in the format:

Year(4),Month(2),Day(2),Hour(2),Minute(2),Second(2)
20070724010101
Jay Damon
Ranch Hand

Joined: Jul 31, 2001
Posts: 282
Look at:SimpleDateFormat The Javadoc contains patterns that are similar.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Creating a String from DateTime