SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
也可以:
SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日");
然后:
字符串转Date
Date date=sdf.parse("2002-10-8 15:30:22");
或者Date转字符串
String datestr=sdf.format(new Date());
2024-03-15 22:28:12
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
也可以:
SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日");
然后:
字符串转Date
Date date=sdf.parse("2002-10-8 15:30:22");
或者Date转字符串
String datestr=sdf.format(new Date());