• Post Reply Bookmark Topic Watch Topic
  • New Topic

String convert in to Date format  RSS feed

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i just want convert String date "2010-09-08T14:10:03.220Z"
in to Date format in java to enter in Oracle database
please give me some solutions
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Refer SimpleDateFormat from google. I think you can able to get solution.
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
reena Mehta wrote:please give me some solutions

It doesn't work like that. You must try and build something on your own and if you encounter problems then we'll be happy to help.
 
Ranch Hand
Posts: 248
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you pass this string to Date class object and use it in database.
 
Thakur Sachin Singh
Ranch Hand
Posts: 248
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try yourself if you have problem then ask here...this is the good way of learning.
 
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thakur Sachin Singh wrote:you pass this string to Date class object and use it in database.

That's why he wants to convert it into Date...
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
reena Mehta wrote:i just want convert String date "2010-09-08T14:10:03.220Z"

That format looks like the standard ISO 8601 format for dates and times.

Unfortunately, the standard Java API classes don't have very good support for that format. If the timezone indication (the letter "Z" at the end of your example) is always that, and can't be some other offset as defined by ISO 8601, then you can parse this string with a SimpleDateFormat without problems. But suppose that it's an offset such as "+01:00", then unfortunately SimpleDateFormat can't deal with that very well (it supports timezone offsets without the semi-colon, for example "+0100", but not with the semi-colon).

If you need really robust support for ISO 8601 format dates and times, I'd recommend you to use the Joda Time library.
 
Thakur Sachin Singh
Ranch Hand
Posts: 248
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can also use parse() method for conversion.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!