cancel
Showing results for 
Search instead for 
Did you mean: 

problem in date formatting DD-MMM-YYYY

Former Member
0 Kudos

Hi,

I am writing a method in my Application:

//@@begin FormatDate()

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");

Date d;

String OutDate = "";

try {

d = dateFormat.parse(InDate);

dateFormat.applyPattern("DD-MMM-YYYY");

OutDate = dateFormat.format(d);

} catch (ParseException e) {

wdComponentAPI.getMessageManager().reportWarning("Date Parse Exception");

}

return (OutDate);

//@@end

The OutDate that I get is in Format DD-MMM-YYYY but MMM is in digits instead of letters i.e. for 2007-07-31 it gives 31-007-2007 instead of 31-Jul-2007.

Any clues to get proper output??

I have tried applying format DD-MON-YYYY it too doesn't help.

Thanks

Anagha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Try this one:

    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    try
    {
      Date birthday = df.parse("1966-09-03");
      df.applyPattern("dd-MMM-yyyy");
      System.out.println(df.format(birthday));
    }
    catch (ParseException e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

See also http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html

Armin

Answers (1)

Answers (1)

Former Member
0 Kudos