添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
		LocalDateTime time = LocalDateTime.of(2014, 11, 9, 0, 0);
        int plusDays = 1000;
        LocalDateTime time1 = time.plusDays(plusDays);
        System.out.println("1000天后的时间为:" + time1);

同时支持几秒后,几小时后等等(如下图)
在这里插入图片描述

Java的Date,Calendar型使用起来并不是很方便,而且Date(据说)有着线程不安全等诸多弊端。同时若不进行封装,会在每次使用时特别麻烦。于是Java8推出了线程安全、简易、高可靠的时间包。并且数据库中也支持LocalDateTime型,在数据存储时候使时间变得简单。Java8这次新推出的包括三个相关的时间型:LocalDateTime年月日十分秒;LocalDate日期LocalTime时间;三个包的方法都差不多。 使用Date的弊端 使用Date输出的日期可读性差(在不进行日期
当前时间:2019年10月24日。距离 JDK 14 发布时间(2020年3月17日)还有多少天? // 距离JDK 14 发布还有多少天? LocalDate jdk14 = LocalDate.of(2020, 3, 17); LocalDate nowDate = LocalDate.now(); System.out.println("距离JDK 14 发布还有:"+nowDate.unt...
当你在做有关时间日期的操作时,你会想到用Date; 当你在做日期、月份、天数相加减时,你会想到用Calendar; 当你需要对时间日期进行格式化时,你会想到使用SimpleDateFormat或DateFormat下的其他子; 但是,你必须知道,以上有关的时间日期操作对象,都是可变的、线程不安全的,同时,如果作为一个经常写过 Calendar calendar1 = Calendar.getInstance(); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd"); calendar1.add(Calendar.DATE, -3); String three_days_ago...
private LocalDateTime getExpirationTime(Integer number){ Calendar calendar = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); calendar.add(Calendar.DATE, number); String three_days_after = sdf.format(calendar.
Calendar:它为特定瞬间与一组诸如 YEAR、MONTH、DAY_OF_MONTH、HOUR 等日历字段之间的转换提供了一些方法,并为操作日历字段(例如获得下星期的日期)提供了一些方法。 Calendar calendar2 = Calendar.getInstance(); SimpleDateFormat sdf2 = new SimpleDateFormat("yyy...
单不饱和脂肪酸: 试了试这个方法 还是不行啊[code=plain] PS E:\Users\DELL\PycharmProjects\pythonProject> pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pygrib==2.1.4 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting pygrib==2.1.4 Using cached https://pypi.tuna.tsinghua.edu.cn/packages/d7/75/96eee88f4889507f72925b7e43be727a5fab0cae1b27fc54b3906bdf828c/pygrib-2.1.4.tar.gz (21.8 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing wheel metadata ... done Requirement already satisfied: numpy in c:\users\dell\anaconda3\envs\jiangyalin\lib\site-packages (from pygrib==2.1.4) (1.21.4) Collecting pyproj Using cached https://pypi.tuna.tsinghua.edu.cn/packages/27/0a/a997c71dfecb4931f75441e44f5f4a99cc407e5c42d41b95be9fceb28c68/pyproj-3.3.0-cp38-cp38-win_amd64.whl (6.3 MB) Requirement already satisfied: certifi in c:\users\dell\anaconda3\envs\jiangyalin\lib\site-packages (from pyproj->pygrib==2.1.4) (2021.10.8) Building wheels for col [/code] Java中的LocalDateTime类的一个例字 从零开始的数据猿: 感谢博主分享,讲的挺不错,希望后面有更多的文章。