获取当前日期年月日时分

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
Date date = new Date(System.currentTimeMillis());
String time = simpleDateFormat.format(date);
int year = Integer.parseInt(time.substring(0, 4));
int month = Integer.parseInt(time.substring(5, 7));
int day = Integer.parseInt(time.substring(8, 10));
int hour = Integer.parseInt(time.substring(12, 14));
int minute = Integer.parseInt(time.substring(15, 17));

猜你喜欢

转载自blog.csdn.net/qq_38373150/article/details/80051103