Life in my own company

Its all up to me.
posts - 137, comments - 166, trackbacks - 113

My Links

News



Twitter



Tag Cloud

Archives

Post Categories

Play

Work

Ugh--more Java

Something as simple as Date parsing in Java is a nightmare.

Suppose the following:

users can pass in dates, and I may not know what format the dates are in.  For example, I may get MM/dd/yyyy or M/d/yyyy or MM/dd/yyyy hh:mm:ss or whatever.

In Java, there is no easy way to parse all of those formats.  They say, “Use the SimpleDateFormatter”, but the simple date formatter throws an exception when you try to parse a date such as 06/01/2006 and says it's an invalid date.  So if you create a SimpleDateFormatter with a pattern of “MM/dd/yyyy”, EVERYTHING outside of that pattern now breaks (such as MM/dd/yyyy hh:mm:ss).  ARGH!

If you know, and can enforce, the format before time, this isn't a big deal, but it FORCES you to only allow certain formats, which is painful.

Microsoft got this right with DateTime.Parse().

Print | posted on Wednesday, September 20, 2006 11:15 AM | Filed Under [ Work ]

Feedback

No comments posted yet.

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 2 and 2 and type the answer here:

Powered by: