问题描述
java编程:查询出当前星期的星期六是几号?
解决方案
public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 7 - calendar.get(Calendar.DAY_OF_WEEK)); System.out.println("Satarday is:" + calendar.get(Calendar.DATE)); }
解决方案二:
Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY); System.out.println(cal.getTime()); System.out.println(cal.get(Calendar.DAY_OF_MONTH));
时间: 2024-10-05 14:59:51