用SimpleDateFormat求出哪天是星期几,如2008-11-11
题目5: 巧妙利用SimpleDateFormat求出: 2008-11-11是星期几?
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
public class Test {
public static void main(String[] args) {
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
Date mydate = null;
try {
mydate= myFormatter.parse("2008-11-11");
} catch (ParseException e) {
e.printStackTrace();
}
SimpleDateFormat formatter4 = new SimpleDateFormat("E");
String mydate3=formatter4.format(mydate);
System.out.println("2008-11-11是"+ mydate3);
}
}
更多内容请见原文,原文转载自:https://blog.csdn.net/qq_44639795/article/details/103123309