如何解析 new 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.
有人吗?
推荐答案
该格式在 Date#toString()
.
将此Date
对象转换为以下形式的String
:
Converts this
Date
object to aString
of the form:
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.
这篇关于如何解析 new Date().toString() 的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!