Problems with date parsing
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Nigel_Smith
Posted On:   Thursday, December 19, 2002 02:55 PM

I have 2 seperate systems on seperate machines. On the first system this works OK: DateFormat simple = DateFormat.getDateInstance(DateFormat.MEDIUM); String periodStartS = "22/11/2002" d = simple.parse(periodStartS); On the second system it does not work returning an exception : java.text.ParseException: Unparseable date However if I change the formatting style to SHORT it works e.g. DateFormat simple = DateFormat.getDateInstance(DateFormat.SHORT); String periodStartS = "22/11/2002" d = simple.parse(periodStartS); The regional date settings on each machine are exactly the same.    More>>

I have 2 seperate systems on seperate machines.


On the first system this works OK:

			
DateFormat simple = DateFormat.getDateInstance(DateFormat.MEDIUM);
String periodStartS = "22/11/2002"
d = simple.parse(periodStartS);



On the second system it does not work returning an exception :

java.text.ParseException: Unparseable date



However if I change the formatting style to SHORT it works


e.g.
			
DateFormat simple = DateFormat.getDateInstance(DateFormat.SHORT);
String periodStartS = "22/11/2002"
d = simple.parse(periodStartS);


The regional date settings on each machine are exactly the same.

What makes the difference?    <<Less

Re: Problems with date parsing

Posted By:   Stephen_McConnell  
Posted On:   Friday, December 20, 2002 06:01 AM

Directly from the JavaDoc on DateFormat


SHORT is completely numeric, such as 12.13.52 or 3:30pm

MEDIUM is longer, such as Jan 12, 1952

LONG is longer, such as January 12, 1952 or 3:30:32pm

FULL is pretty completely specified, such as Tuesday

April 12, 1952 AD or 3:30:42pm PST.


I do know the JavaDoc by Sun is not always the most user-friendly thing in the world, but it contains a world of answers.


Stephen McConnell

About | Sitemap | Contact