0

Can you help me with source code to get the date 1 jan 2009 in the format
01 01 09.

Actually I've to form a verification id for issuing gatepass which uses last two digit of the year,then net two digit consist of month and next three digit consist of number from 001 to 999 which increment by 1.

Please help me it's urgent.

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by javaAddict
0

SimpleDateFormat class is needed

......
       String yourdate="12-Aug-2009";
       String currformat="dd-MMM-yyyy";
       SimpleDateFormat fd=new SimpleDateFormat(currformat);
       Date d1=fd.parse(yourdate);

       System.out.println(d1);
       String newformat="dd-MM-yyyy";
       fd.applyPattern(newformat);
       StringBuffer b=new StringBuffer();
       System.out.println(fd.format(d1,b,new FieldPosition(0)));
       ....
0

SimpleDateFormat class is needed

......
       String yourdate="12-Aug-2009";
       String currformat="dd-MMM-yyyy";
       SimpleDateFormat fd=new SimpleDateFormat(currformat);
       Date d1=fd.parse(yourdate);

       System.out.println(d1);
       String newformat="dd-MM-yyyy";
       fd.applyPattern(newformat);
       StringBuffer b=new StringBuffer();
       System.out.println(fd.format(d1,b,new FieldPosition(0)));
       ....

You could have printed this:

//fd.format(d1)
System.out.println( fd.format(d1) );
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.