81,091
社区成员
发帖
与我相关
我的任务
分享
// 替换成你从数据库中获取的 date
Date dateFromDB = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
String strDate = df.format(dateFromDB);
System.out.println("year="+strDate.substring(0,4));
System.out.println("month="+strDate.substring(5,7));
System.out.println("day="+strDate.substring(8,10));
} catch (Exception e) {
e.printStackTrace();
}