• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

change data type from string to timestamp

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[/b]
[ June 08, 2006: Message edited by: Ankur Sharma ]
 
elli dian
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic