在格式化日期的基础上添加星期几

 

 

package zuoye;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Demo07 {

    public static void main(String[] args) {

        Date date = new Date();

        String week = "星期" + date.getDay();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String time = simpleDateFormat.format(date);

        System.out.println(time + " " + week);
    }
}

 

 

 

 

 

 

这种题目的解决方法有多种,本种方法仅供参考

 

posted @ 2019-08-01 11:17  AxeBurner  阅读(562)  评论(0编辑  收藏  举报