aspose file tools
The moose likes Beginning Java and the fly likes String convert in to Date format Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "String convert in to Date format" Watch "String convert in to Date format" New topic
Author

String convert in to Date format

reena Mehta
Greenhorn

Joined: Nov 17, 2010
Posts: 24

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
Eswar Nec
Ranch Hand

Joined: May 02, 2010
Posts: 105
Hi,

Refer SimpleDateFormat from google. I think you can able to get solution.


Wake up! Don't let your smile be snatched away by anybody!
Regards, Eswar
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

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.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 209

you pass this string to Date class object and use it in database.


my blog SCJP 6- 91%, IBM DB2, IBM RAD Certified
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 209

try yourself if you have problem then ask here...this is the good way of learning.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14672
    
  11

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...


[My Blog]
All roads lead to JavaRanch
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12926
    
    3

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 209

you can also use parse() method for conversion.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: String convert in to Date format
 
Similar Threads
String to Date?
Date Comparison in Java
how to convert String into Date format
How to convert this String into a readable date?
String conversion