当前位置: 首页 > news >正文

蓝衫网站建设如何用wordpress

蓝衫网站建设,如何用wordpress,网站建设文化传播有限公司,网站建设的维护与更新LocalDateTime java8使用了LocalDateTime和DateTimeFormatter。比之前的Date和Carlendar有所改进。 DateTimeFormatter是线程安全的。DateTimeFormatter中很多属性使用了final修饰。 LocalDate: 只能设置仅含年月日的格式#xff0c;表示没有时区的日期, LocalDate是不可变并…LocalDateTime java8使用了LocalDateTime和DateTimeFormatter。比之前的Date和Carlendar有所改进。 DateTimeFormatter是线程安全的。DateTimeFormatter中很多属性使用了final修饰。 LocalDate: 只能设置仅含年月日的格式表示没有时区的日期, LocalDate是不可变并且线程安全的 LocalTime: 只能设置仅含时分秒的格式表示没有时区的时间, LocalTime是不可变并且线程安全的 LocalDateTime: 可以设置含年月日时分秒的格式 表示没有时区的日期时间, LocalDateTime是不可变并且线程安全的 ZoneId: 时区ID用来确定Instant和LocalDateTime互相转换的规则 Instant: 用来表示时间线上的一个点瞬时 Clock: 用于访问当前时刻、日期、时间用到时区 Duration: 用秒和纳秒表示时间的数量长短用于计算两个日期的“时间”间隔 构建LocalDateTime对象 public void generateLocalDate() {LocalDate date LocalDate.of(2000, 1, 8);LocalDateTime dateTime LocalDateTime.of(2020, 1, 8, 15, 16, 17);System.out.println(date date);System.out.println(dateTime: dateTime);}获取LocalDateTime的年月日 public void getLocalDateTimeMonth() {LocalDateTime dateTime LocalDateTime.of(2020, 1, 8, 15, 16, 17);int yeardateTime.getYear();int monthdateTime.getMonth().getValue();int daydateTime.getDayOfMonth();System.out.println(dateTime对应的年份为year);System.out.println(dateTime对应的月份为month);System.out.println(dateTime对应的天数为day);}字符串String转LocalDateTime public void stringToTime() {DateTimeFormatter formatter DateTimeFormatter.ofPattern(yyyy-MM-dd HH:mm:ss);String datetimeText 2020-04-01 23:59:59;LocalDateTime localDateTime LocalDateTime.parse(datetimeText, formatter);// LocalDateTime的toString()方法在日期和时间中间加入了T字符串System.out.println(localDateTime);}LocalDateTime 转字符串String public void localDateTimeToString() {DateTimeFormatter formatter DateTimeFormatter.ofPattern(yyyy-MM-dd HH:mm:ss);LocalDateTime dateTime LocalDateTime.of(2020, 1, 8, 15, 16, 17);String dateTimeStr dateTime.format(formatter);System.out.println(dateTimeStr为 dateTime);}LocalDateTime 转时间戳毫秒 public static long getMillsByLocalDateTime(LocalDateTime localDateTime) {long mills localDateTime.toInstant(ZoneOffset.of(8)).toEpochMilli();return mills;}时间戳毫秒转LocalDateTime public static LocalDateTime getLocalDateTimeByMills() {long mills 1640419285000L;LocalDateTime result new Date(mills).toInstant().atOffset(ZoneOffset.of(8)).toLocalDateTime();return result;}Date转Instant Instant instant date.toInstant();Instant转Date Date date Date.from(instant);Date转LocalDateTime public static void dateToLocalDateTime(Date date) {Instant dateInstant date.toInstant();LocalDateTime localDateTime LocalDateTime.ofInstant(dateInstant, ZoneId.systemDefault());}LocalDateTime转Date public static Date parse(LocalDateTime localDateTime) {return Date.from(localDateTime.atZone( ZoneId.systemDefault()).toInstant());}LocalDateTime 获取LocalDate LocalDate localDate localDateTime.toLocalDate();LocalDateTime 获取LocalTime LocalTime localTime localDateTime.toLocalTime();LocalDate Date转LocalDate public void dateToLocalDate(Date date) {Instant dateInstant date.toInstant();LocalDate localDate LocalDateTime.ofInstant(dateInstant, ZoneId.systemDefault()).toLocalDate();}LocalDate转Date public static Date parse(LocalDate localDate) {return Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());}localDate转String public static String localDateToString(Date date) {Instant dateInstant date.toInstant();LocalDate localDate LocalDateTime.ofInstant(dateInstant, ZoneId.systemDefault()).toLocalDate();// localDate转String DateTimeFormatter formatter DateTimeFormatter.ofPattern(yyyy-MM-dd);String localDateStr localDate.format(formatter);System.out.println(localDateStr);return localDateStr;}String转LocalDate public static void stringToLocalDate() {DateTimeFormatter formatter DateTimeFormatter.ofPattern(yyyy-MM-dd);String datetimeText 2020-04-01;LocalDate localDate LocalDate.parse(datetimeText, formatter);System.out.println(localDate);}LocalDate获取年月日: int year localDate.getYear();int monthValue localDate.getMonthValue();int dayOfMonth localDate.getDayOfMonth(); LocalDate修改年月日 public static void changeYearMonthDay() {LocalDate localDate LocalDate.now();//修改年份LocalDate withYearResult localDate.withYear(2020);//修改月份LocalDate withMonthResult localDate.withMonth(5);//修改日LocalDate withDayResult localDate.withDayOfMonth(20);System.out.println( withYearResult withMonthResult withDayResult);}LocalDate比较日期大小compareTo compareTo()方法 在两边相等的情况下返回 0 在左边大于右边时返回 1  在左边小于右边时返回 -1 public static void localDateCompareTo() {DateTimeFormatter formatter DateTimeFormatter.ofPattern(yyyy-MM-dd);String datetimeText 2020-04-01;LocalDate localDate LocalDate.parse(datetimeText, formatter);LocalDate nowDate LocalDate.now();System.out.println(localDate);System.out.println(nowDate:nowDate);if (nowDate.compareTo(localDate) 0) {System.out.println(nowDate小于 datetimeText);} else {System.out.println(nowDate大于等于 datetimeText);}}LocalDate比较日期的前后 after 只在大于情况下才为true (相等时不会 before 只在小于情况下才为true (相等时不会 public static void isBeforeAfter() {DateTimeFormatter formatter DateTimeFormatter.ofPattern(yyyy-MM-dd);String datetimeText 2020-04-01;LocalDate localDate LocalDate.parse(datetimeText, formatter);LocalDate nowDate LocalDate.now();System.out.println(localDate);System.out.println(nowDate:nowDate);if (nowDate.isBefore(localDate)) {System.out.println(nowDate 在 datetimeText 之前);} else {System.out.println(nowDate 在 datetimeText 之后);}}获取日期差距 / 获取日期时间间隔 public static void durationDateTime() {LocalDateTime date3 LocalDateTime.now();LocalDateTime date4 LocalDateTime.of(2018, 1, 13, 22, 30, 10);Duration duration Duration.between(date3, date4);System.out.println(date3 与 date4 间隔 \n 天 : duration.toDays() \n 时 : duration.toHours() \n 分 : duration.toMinutes() \n 毫秒 : duration.toMillis() \n 纳秒 : duration.toNanos() \n);}日期时间计算 public void addMonthDay() {LocalDateTime dt LocalDateTime.of(2020, 1, 26, 20, 30, 59);System.out.println(dt);// 加5天减3小时:LocalDateTime dt2 dt.plusDays(5).minusHours(3);System.out.println(dt2); // 2019-10-31T17:30:59// 减1月:LocalDateTime dt3 dt2.minusMonths(1);System.out.println(dt3); // 2019-09-30T17:30:59}LocalTime LocalTime获取时分秒 //获取小时int hour localTime.getHour();int hour1 localTime.get(ChronoField.HOUR_OF_DAY);//获取分int minute localTime.getMinute();int minute1 localTime.get(ChronoField.MINUTE_OF_HOUR);//获取秒int second localTime.getMinute();int second1 localTime.get(ChronoField.SECOND_OF_MINUTE);参考资料 https://www.liaoxuefeng.com/wiki/1252599548343744/1303871087444002 https://blog.csdn.net/weixin_38405253/article/details/100765007 https://www.jianshu.com/p/048ee8580639
http://www.zqtcl.cn/news/848582/

相关文章:

  • node做网站怎么知道蜘蛛来过怎么学网站设计
  • 青海省建设厅网站公示公告简单建站
  • 手机网站用什么后台wordpress 百度蜘蛛
  • 网站文章伪原创怎么做手机网站 程序
  • 网站建设每月工作多少开发小程序的目的
  • 社区网站建设方案pptwordpress用户名在哪看
  • 浙江企业响应式网站建设公司简介如何写
  • 自己做静态网站的步骤店面设计在线
  • 活动汪活动策划网站wordpress 无法保存
  • 门户网站开发案例兰州需要做网站的公司有哪些
  • 东莞企业网站asp网站怎么安装
  • 个人做公司网站网站备案取消接入
  • 崇信网站建设it外包的收益主要有哪些
  • 安陆做网站多少钱免费网站定制
  • 快递网站模版长春好的做网站公司有哪些
  • 怎么利用公司网站开发客户网站建设重点步骤
  • 网站站内推广用个人电脑做网站的步骤
  • 网站设计主要包含3个方面陕西城乡住房建设部网站
  • 专门做汽车配件的网站东莞招聘网有哪些比较好
  • 网站前台怎么套用织梦后台小网站怎么建设
  • 网站框架代码深圳手机网站设计
  • 更改网站主题九江建网站的公司
  • 如何分析一个网站网站页面建设
  • 做网站好网页制作3个网页的网站图片
  • 合肥网站建设网站推广新的网站建设一般多少钱
  • 北京网站改版哪家好网站关键词怎样做优化
  • 网站开发行业分析wordpress 粘贴表格
  • 网站开发的招标参数网络科技公司网站源码下载
  • 属于网络营销站点推广的是seo好wordpress主题
  • j2ee只做网站阿里企业邮箱免费