我知道日期格式,例如
"yyyy-mm-dd" -which以2011-02-26格式显示日期
"yyyy-MMM-dd"-which以2011-FEB-26格式显示日期
用于例如:
SimpleDateFormat formatter = new SimpleDateFormat(
"yyyy/MMM/dd ");我想要一个格式,可以帮助我显示一周中的某一天,如2011-02-MON或任何东西。我只希望一周中的某一天显示为包含月份和年份的字符。你能告诉我像这样的格式吗?
发布于 2011-02-26 04:01:00
这应该显示'Tue':
new SimpleDateFormat("EEE").format(new Date());这应该显示‘星期二’:
new SimpleDateFormat("EEEE").format(new Date());这应该显示'T':
new SimpleDateFormat("EEEEE").format(new Date());因此,您的特定示例将是:
new SimpleDateFormat("yyyy-MM-EEE").format(new Date());发布于 2011-02-26 04:02:17
是的--“E”确实有效。
http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
Date date = new Date();
DateFormat df = new SimpleDateFormat("yyyy-MM-E");
System.out.println(df.format(date));发布于 2013-09-28 00:07:38
SimpleDateFormat sdf=new SimpleDateFormat("EEE");例如,EEE代表星期几,星期四显示为清华。
https://stackoverflow.com/questions/5121976
复制相似问题