java获取当前日期前三位,即星期几?

2024-11-29 20:36:16
推荐回答(1个)
回答1:

Calendar calendar = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("yyyy-M-d");
String s = df.format(calendar.getTime());
System.out.println(s);
System.out.println(calendar.get(Calendar.DAY_OF_WEEK)-1);
因为星期是从周日开始的