|
How to convert a String to date
|
|
07-10-2008, 07:55 PM
Post: #1
|
|||
|
|||
|
How to convert a String to date
How do I convert a String to date?
|
|||
|
07-10-2008, 08:59 PM
Post: #2
|
|||
|
|||
|
RE: How to convert a String to date
What is your date format? You can use the SimpleDateFormat for doing it.
|
|||
|
07-10-2008, 09:01 PM
Post: #3
|
|||
|
|||
|
RE: How to convert a String to date
Converting a string to date is easy
[java] String date ="01/21/2008"; Date dt = new Date(date); System.out.println(dt); [/java] |
|||
|
07-10-2008, 09:06 PM
Post: #4
|
|||
|
|||
|
RE: How to convert a String to date
My String contains date in the below format.
21.1.2008. programmer, I tried with the you said. It is throwing me an IllegalArgumentException. |
|||
|
07-10-2008, 09:09 PM
Post: #5
|
|||
|
|||
|
RE: How to convert a String to date
[java]
String date ="21.1.2008"; SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy"); Date dt = format.parse(date); System.out.println(dt); [/java] Try the above code. |
|||
|
07-10-2008, 09:34 PM
Post: #6
|
|||
|
|||
|
RE: How to convert a String to date
Sorry my code will work only if the date format is dd/mm/yyyy. The SimpleDateFormat is the right choice to go
|
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)





