集册 Java实例教程 使用SimpleDateFormat格式化星期几

使用SimpleDateFormat格式化星期几

欢马劈雪     最近更新时间:2020-01-02 10:19:05

484
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用SimpleDateFormat格式化星期几


import java.text.SimpleDateFormat;

import java.util.Date;

 
 /*
  from NowJava.com 
 */

public class Main {

 

  public static void main(String[] args) {

     Date date = new Date();

   

     //formatting day of week in E format like Sun, Mon etc.

     String strDateFormat = "E";

     SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);

     

     System.out.println("Current day of week in E format : " + sdf.format(date));

     

     //formatting day of week in EEEE format like Sunday, Monday etc.

     strDateFormat = "EEEE";

     sdf = new 
展开阅读全文