| Author |
change data type from string to timestamp
|
elli dian
Greenhorn
Joined: May 18, 2006
Posts: 15
|
|
I wanto to change data type from string to timestamp, but I get a not suitable value according format DD-MM-YYYY My coding : String fdate="02-05-2006"; SimpleDateFormat dateFormat = new SimpleDateFormat("DD-MM-yyyy"); java.util.Date parsedFDate = dateFormat.parse(fdate); java.sql.Timestamp fdateabsence=new java.sql.Timestamp(parsedFDate.getTime()); I get result=2006-01-02 00:06:00.0 Please help me... so I get result according my fdate is=02-05-006 and data type will be timestamp
|
 |
Ankur Sharma
Ranch Hand
Joined: Dec 27, 2005
Posts: 1234
|
|
[/b] [ June 08, 2006: Message edited by: Ankur Sharma ]
|
The Best way to predict your future is to create it
Ankur Sharma
|
 |
elli dian
Greenhorn
Joined: May 18, 2006
Posts: 15
|
|
I get still a false value: if I use format dd-MM-yyyy the result is:2006-05-02, but I want to get a value:02-05-2006. Please help me again?
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12907
|
|
Maybe you don't understand the difference between a Timestamp object and the string representation of a Timestamp object. A Timestamp object contains a date and time. It does not have a specific format by itself. If you call toString() on a Timestamp, you might get a String that looks like "2006-01-02 00:06:00.0". The toString() method uses a default format, because it has to convert the date and time value into a String somehow. But again, the format itself is not a property of the Timestamp object. If you want to convert the Timestamp object to a String with a specific format, you need to use the SimpleDateFormat.format(...) method, which allows you to specify a specific format.
|
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: jrebel
|
|
subject: change data type from string to timestamp
|
|
|