| Author |
Converting the date format
|
poornima balagopal
Ranch Hand
Joined: Dec 02, 2003
Posts: 83
|
|
Hi I have a string with a value "12-12-03" or a string which contain a date in the above format. I want to convert 12-12-03(which is a String ) into 12-Dec-03 format. If anybody knows the simple way to do this please help me . This is a small outline what i am doing String startdate=objForm.getStartDate(); ArrayList paramList=new ArrayList(); paramList.add(0,startdate); The value in the String startDate will be in the format i mentioned above which i have to convert as 12-dec-03 format before adding into the ArrayList. So Please help me . Thanks in advance
|
 |
Anurag Mishra
Ranch Hand
Joined: Jun 16, 2003
Posts: 121
|
|
Hi, pls use SimpleDateFormat class in package java.text.SimpleDateFormat youcan check details in jdk docs and can use same to get date in a format whatever you want. thanks
|
SCJP 1.2
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
A hint - you might use two SimpleDateFormat objects - one to specify your input format for parsing, and another to specify your output format. For a completely different approach, you might break your input string on dashes into three strings (see StringTokenizer), look up the "Dec" string using the "12" string (see Map) and then put the parts back together. Let us know how it works out!
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
 |
|
|
subject: Converting the date format
|
|
|