public class Work01 {
public static void main(String[] args){
}
public static void function1(){
System.out.println("请输入日期:");
String s=new Scanner(System.in).nextLine();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日");//自己定义的格式
String str=sdf.format(s);//将日期格式化为上面自己定义的格式
System.out.println(str);
}
}
异常如下:xception in thread "main" java.lang.IllegalArgumentException: Cannot format given Object as a Date |
|