Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

converting string datetime object to date object.  RSS feed

 
amarshi mohanty
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How to convert string date_time object to Date object.


 
Varun Chopra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
amarshi mohanty wrote:Hi,

How to convert string date_time object to Date object.



Look at java.text.DateFormat and parse method
 
Amit Vinod Dali
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amid, please UseCodeTags. Also, that code won't work. The pattern clearly does not match the provided string.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15860
80
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!