import java.text.ParseException;
import java.util.Calendar;
public class DateDemo
{
public static void main(String [] args) throws ParseException
{
Calendar c = Calendar.getInstance();
int year =c.get(Calendar.YEAR);
int month =c.get(Calendar.MONTH)+1;
int day =c.get(Calendar.DAY_OF_MONTH);
int week =c.get(Calendar.DAY_OF_WEEK);
System.out.println(year+"年 ,"+month+"月,"+day+"日,"+"星期"+week);
}
}
import java.text.ParseException;
import java.util.Calendar;
public class DateDemo
{
public static void main(String [] args) throws ParseException
{
Calendar c = Calendar.getInstance();
int year =c.get(Calendar.YEAR);
int month =c.get(Calendar.MONTH)+1;
int day =c.get(Calendar.DAY_OF_MONTH);
int week =c.get(Calendar.DAY_OF_WEEK);
System.out.println(year+"年 ,"+month+"月,"+day+"日,"+getWeek(week));
}
private static String getWeek(int week) {
String[] week_form= {"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
return week_form[week-1];
}
}
————————————————
版权声明:本文为CSDN博主「明明如月学长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/w605283073/article/details/46572437