aspose file tools*
The moose likes Java in General and the fly likes converting string datetime object to date object. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "converting string datetime object to date object." Watch "converting string datetime object to date object." New topic
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: 211
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) - Online Certifications - Webner Solutions
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: 19541
    
  16

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13869
    
  10

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: converting string datetime object to date object.
 
Similar Threads
Displaying the Date - Issue
String to date conversion
axis
SOAP with attachments, 3 questions
Need Help regarding -- org.xml.sax.SAXException: Invalid element