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.

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)));
       ....

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) );
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.