jdk1.8的取当前时间

取当前时间(jdk1.8)用法

//获取当前日期(年月日时分秒) LocalDateTime date =LocalDateTime.now();

//当前时间的时间戳 Timestamp timestamp= Timestamp.valueOf(LocalDateTime.now());

// 获取当前日期(年-月-日) LocalDate time = LocalDate.now();

// 设置日期 of(年份, 月份, 月中的天数) LocalDate of = LocalDate.of(2020, 10, 1);

// 获取年 time.getYear();

// 获取月 time.getMonth();

// 获取当前月的天数 time.getDayOfMonth();

// 获取一年中的天数 time.getDayOfYear();

// 获取当天星期几 time.getDayOfWeek();

posted @ 2020-08-14 20:20  Pseudo-lover  阅读(1497)  评论(0)    收藏  举报