It's not a secret anymore!*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes SimpleDateFormat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "SimpleDateFormat" Watch "SimpleDateFormat" New topic
Author

SimpleDateFormat

Mike Hays
Greenhorn

Joined: May 15, 2009
Posts: 14
Hello again,

Does anyone know if its OK to use SimpleDateFormat in this project? The documentation for constructors in this class says "This constructor may not support all locales. For full coverage, use the factory methods in the DateFormat class." Is this not portable enough?
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5216
    
  12

Hi Mike,

I just handled the dates as Strings, so no conversions or formatting (because you don't need it to find and book rooms). But a SimpleDateFormat will do the job. Although if I'm not mistaken it generates a valid date, also when you have a String that doesn't exactly match the pattern. More info can be found here.

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2265
    
    3

Howdy, Mike!

Roel De Nijs wrote:I just handled the dates as Strings, so no conversions or formatting (because you don't need it to find and book rooms).


Me too! And Mike, since you are not required to format them, my advice would be to keep things as simple as possible and not to format them.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SimpleDateFormat