代码:可直接拷贝使用
long time=System.currentTimeMillis();
Date date=new Date(time);
SimpleDateFormat format=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒 EEEE");
LogUtil.e("time","time1="+format.format(date)); //time1 = 2019年08月21日 10时22分58秒 星期三
format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
LogUtil.e("time","time2="+format.format(date)); //time2 = 2019-08-21 10:22:58
format=new SimpleDateFormat("yyyy/MM/dd");
LogUtil.e("time","time3="+format.format(date)); //time3 = 2019/08/21
format=new SimpleDateFormat("HH:mm:ss");
LogUtil.e("time","time4="+format.format(date)); //time4 = 10:22:58
format=new SimpleDateFormat("EEEE");
LogUtil.e("time","time5="+format.format(date)); //time5 = 星期三
format=new SimpleDateFormat("E");
LogUtil.e("time","time6="+format.format(date)); //time6 = 周三
输出结果: