| Author |
converting string datetime object to date object.
|
amarshi mohanty
Ranch Hand
Joined: Jul 01, 2008
Posts: 110
|
|
Hi,
How to convert string date_time object to Date object.
|
SCJP (97%), SCWCD (95%))
|
 |
Varun Chopra
Ranch Hand
Joined: Jul 10, 2008
Posts: 204
|
|
amarshi mohanty wrote:Hi,
How to convert string date_time object to Date object.
Look at java.text.DateFormat and parse method
|
-Varun -
(My Blog) - Mock Tests
|
 |
Amit Vinod Dali
Ranch Hand
Joined: Apr 14, 2010
Posts: 42
|
|
import java.text.SimpleDateFormat;
import java.util.Date;
try
{
SimpleDateFormat dateDisplayFormat = new SimpleDateFormat("dd/MM/yyyy");
Date date = dateDisplayFormat.parse("2010-58-14 03:58:02");
}
catch (ParseException pe)
{
// Handle Exception here
}
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Amid, please UseCodeTags. Also, that code won't work. The pattern clearly does not match the provided string.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12928
|
|
amarshi mohanty wrote:
That date looks really strange. What is it supposed to mean? The 14th day of the 58th month of 2010? Or the 58th day of the 14th month of 2010?
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
 |
|
|
subject: converting string datetime object to date object.
|
|
|