有没有日期格式在java中显示星期几? [英] Is there a date format to display the day of the week in java?

查看:312
本文介绍了有没有日期格式在java中显示星期几?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道日期格式,例如:
yyyy-mm-dd,以格式显示日期2011-02-26

yyyy-MMM-dd - 以格式 2011-FEB-26



用于例如:

  SimpleDateFormat formatter = new SimpleDateFormat(
yyyy / MMM / dd);

我想要一种格式,可以帮助我显示像 2011-02-MON 或任何东西。我只想要一周中的日子以月份和年份的字符显示。你可以告诉我这样的格式吗?

解决方案

这应该显示'Tue':

  new SimpleDateFormat(EEE)。format(new Date()); 

这应该显示'星期二':

  new SimpleDateFormat(EEEE)。format(new Date()); 

这应该显示'T':



<$ ($)$新建SimpleDateFormat(EEEEE)格式(new Date());

所以你的具体例子是:



<$ Simple $ Date $($)$ new $($)


I know of date formats such as
"yyyy-mm-dd" -which displays date in format 2011-02-26
"yyyy-MMM-dd"-which displays date in format 2011-FEB-26

to be used in eg:

SimpleDateFormat formatter = new SimpleDateFormat(
                "yyyy/MMM/dd ");

I want a format which would help me display the day of the week like 2011-02-MON or anything. I just want the day of the week to be displayed in characters with the month and the year. Can you tell me of a format like this?

解决方案

This should display 'Tue':

new SimpleDateFormat("EEE").format(new Date());

This should display 'Tuesday':

new SimpleDateFormat("EEEE").format(new Date());

This should display 'T':

new SimpleDateFormat("EEEEE").format(new Date());

So your specific example would be:

new SimpleDateFormat("yyyy-MM-EEE").format(new Date());

这篇关于有没有日期格式在java中显示星期几?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆