Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date simple question

Status
Not open for further replies.

elibb

Programmer
Oct 22, 2001
335
MX
hi, this is a very simple question, but i cannt find the answer, how can i get the actual date (from the system) in the format "yyMMddmmss"
for example if now is october 3, 2003 11:58am i want it to be:

"0310031158"

so i can name a file like that..

if you can post some code, ill be forever thankful.

thank you very much

Eli
 
i checked, but i still cannt make it work.. could You post some code please?

Eli
 
Here is sample code:

Code:
import java.util.*;

 public class CurrentDate {

 public static void  main(String arg[]) {

     Calendar cal = Calendar.getInstance(TimeZone.getDefault());

     String DATE_FORMAT = "yyyyMMddHHmm";
     java.text.SimpleDateFormat sdf =
           new java.text.SimpleDateFormat(DATE_FORMAT);

     sdf.setTimeZone(TimeZone.getDefault());

     System.out.println("The file name will be : " + sdf.format(cal.getTime()));
     }
 }
 
thank you very much JVZ, thats exactly what i needed.

Eli
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top