File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes how to convert date to a string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to convert date to a string" Watch "how to convert date to a string" New topic

how to convert date to a string

Chitti pokala
Ranch Hand

Joined: Jan 11, 2005
Posts: 46
I am using a date fucntion in jsp. I want to convert 2005-01-31 to 31-Jan-2005.

How can I convert this......

Thanks in Advance.
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Have a look at DateFormat and SimpleDateFormat classes in java.text package.

Here's an example -


The future is here. It's just not evenly distributed yet. - William Gibson
Sonny Gill LinkedIn
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63852

Not much to do with JSP, so moved to Java in General (intermediate).

[Asking smart questions] [About Bear] [Books by Bear]
friso dejonge
Ranch Hand

Joined: Jul 11, 2002
Posts: 162

There is a simple answer like the one below. But maybe it is more challenging to read the java tutorial:


swimming certificate (A & B), shoelaces diploma, and some useless java ones.
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

Calculating Java dates: Take the time to learn how to create and use dates
Working in Java time: Learn the basics of calculating elapsed time in Java

Formatting a Date Using a Custom Format
Parsing a Date Using a Custom Format
I agree. Here's the link:
subject: how to convert date to a string
jQuery in Action, 3rd edition