Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to parse output of new Date().toString()

Tags:

I need a date format (maybe SimpleDateFormat) that parses reliable the output I get when I call toString() on a Date object. Output on my german(!) system is: "Sun Dec 12 13:45:12 CET 2010", so it doesn't seem to honor locales, which seems to make it easy.

Anyone?

like image 307
Daniel Avatar asked Jan 17 '11 13:01

Daniel


1 Answers

That format is specified in the Date#toString().

Converts this Date object to a String of the form:

dow mon dd hh:mm:ss zzz yyyy 

So, in SimpleDateFormat pattern terms:

EEE MMM dd HH:mm:ss zzz yyyy 

Unrelated to the problem, I wonder if it wasn't in first place a bad idea to use Date#toString() instead of SimpleDateFormat#format() to output dates. I would consider to fix it straight there.

like image 149
BalusC Avatar answered Oct 05 '22 10:10

BalusC