| Author |
how to parse string to date with defualt format?
|
Simpson Kumar
Ranch Hand
Joined: Mar 19, 2008
Posts: 260
|
|
is there any possibilities to parse a string to date if we don't specify the format in SDF?
In database we have different formats and we need to convert each one convert to date with common format(something like default), is there any possibilities to do in java?
|
Thanks,
Kumar
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
Parsing a date string without knowing the format is impossible in general. Suppose you get the string "07/08/2009" - how can you see if this means 7 August 2009 (DD/MM/YYYY) or 8 July 2009 (MM/DD/YYYY)?
You could do it by trying to parse a string with a different number of formats, but this will not solve the problem of ambiguous dates.
There is no method in the standard Java API to parse a string into a Date object without knowing the format.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
pete stein
Bartender
Joined: Feb 23, 2007
Posts: 1561
|
|
|
Also, please read the FAQ about being forthright when cross-posting the same question in multiple fora. This question has been fully answered in the forums.sun.com fora.
|
 |
 |
|
|
subject: how to parse string to date with defualt format?
|
|
|