如何解析新的Date()。toString()的输出 [英] how to parse output of new Date().toString()
问题描述
我需要一个日期格式(也许是SimpleDateFormat),它可以解析我在Date对象上调用toString()时得到的输出。我的德语(!)系统的输出是:Sun Dec 12 13:45:12 CET 2010,所以它似乎并不尊重语言环境,这似乎很容易。
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.
任何人?
推荐答案
该格式在 日期#toString()
。
将此
日期
对象转换为字符串
表格:
dow mon dd hh:mm:ss zzz yyyy
因此,在 SimpleDateFormat
模式术语:
So, in SimpleDateFormat
pattern terms:
EEE MMM dd HH:mm:ss zzz yyyy
与问题无关,我想知道使用 Date#toString()是不是一开始就不是一个好主意
而不是 SimpleDateFormat #format()
输出日期。我会考虑直接解决它。
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.
这篇关于如何解析新的Date()。toString()的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!