import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
public class Simpledate {
public static void main(String[] args){
Scanner s=
new Scanner(System.
in);
System.out.println(
"请输入你的生日");
String str=
s.next();
//定义一个日期格式化对象
SimpleDateFormat sdf=
new SimpleDateFormat(
"yyyy-MM-dd-HH:mm:ss");
try {
Date birth=
sdf.parse(str);
System.out.println(birth);
sdf=
new SimpleDateFormat(
"MM/dd/yyyy");
String b=
sdf.format(birth);
System.out.println(b);
} catch (ParseException e) {
System.out.println(
"格式错误,不能解析");
e.printStackTrace();
}
}
}
转载于:https://www.cnblogs.com/zyy1130/p/6807372.html
转载请注明原文地址: https://win8.8miu.com/read-1459034.html