• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to Convert timeStamps  RSS feed

 
Ravi Tej Pidatala
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get a String from Text file which is like 2006-05-22 14:04:59.612000000 . I have to convert it into TimeStamp with TimeZone (6) in oracle and save it in database .

I have tried
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSSSSSSSS");
java.util.Date parsedDate = dateFormat.parse("2006-05-22 14:04:59.612000000");

the above code would covert the String into yyyy-MM-dd hh:mm:ss.SSSSSSSSS but the format i need is 26-JUN-12 10.36.22.304900000 PM +00:00 . Is there any way for me to convert timestamp from yyyy-MM-dd hh:mm:ss.SSSSSSSSS into dd-MMM-YY hh:mm:ss.SSSSSSSSS ?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Ravi Tej Pidatala wrote:the above code would covert the String into yyyy-MM-dd hh:mm:ss.SSSSSSSSS but ...

No, what the above code does is parse a String in the format yyyy-MM-dd hh:mm:ss.SSSSSSSSS into a Date object.

A Date object is just a date, just like a number is just a number. It does not have a format by itself. You specify the format to the SimpleDateFormat object at the moment you convert it from or to a String.

After parsing, you can ofcourse convert the Date object back to a String, using another format. But the result will be a String - not a "Date with a specific format" (because Dates don't have a format themselves).
 
Ravi Tej Pidatala
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!