date format

Reply

Join Date: Aug 2008
Posts: 40
Reputation: coolbuddy059 has a little shameless behaviour in the past 
Solved Threads: 0
coolbuddy059 coolbuddy059 is offline Offline
Light Poster

date format

 
0
  #1
Jun 10th, 2009
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.
Last edited by coolbuddy059; Jun 10th, 2009 at 6:42 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1,574
Reputation: BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all 
Solved Threads: 199
BestJewSinceJC BestJewSinceJC is offline Offline
Posting Virtuoso

Re: date format

 
0
  #2
Jun 10th, 2009
SimpleDateFormat

(maybe)
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,612
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 465
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: date format

 
0
  #3
Jun 11th, 2009
SimpleDateFormat class is needed

  1. ......
  2. String yourdate="12-Aug-2009";
  3. String currformat="dd-MMM-yyyy";
  4. SimpleDateFormat fd=new SimpleDateFormat(currformat);
  5. Date d1=fd.parse(yourdate);
  6.  
  7. System.out.println(d1);
  8. String newformat="dd-MM-yyyy";
  9. fd.applyPattern(newformat);
  10. StringBuffer b=new StringBuffer();
  11. System.out.println(fd.format(d1,b,new FieldPosition(0)));
  12. ....
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,658
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 224
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: date format

 
0
  #4
Jun 11th, 2009
Originally Posted by adatapost View Post
SimpleDateFormat class is needed

  1. ......
  2. String yourdate="12-Aug-2009";
  3. String currformat="dd-MMM-yyyy";
  4. SimpleDateFormat fd=new SimpleDateFormat(currformat);
  5. Date d1=fd.parse(yourdate);
  6.  
  7. System.out.println(d1);
  8. String newformat="dd-MM-yyyy";
  9. fd.applyPattern(newformat);
  10. StringBuffer b=new StringBuffer();
  11. System.out.println(fd.format(d1,b,new FieldPosition(0)));
  12. ....
You could have printed this:
  1. //fd.format(d1)
  2. System.out.println( fd.format(d1) );
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC