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

网站台做计么呢宁波最好的seo外包

网站台做计么呢,宁波最好的seo外包,海珠高端网站建设,苏州厂房装修JDK8时间相关类 JDK8时间相关类1.1 ZoneId 时区1.2 Instant 时间戳1.3 ZoneDateTime 带时区的时间1.4DateTimeFormatter 用于时间的格式化和解析1.5LocalDate 年、月、日1.6 LocalTime 时、分、秒1.7 LocalDateTime 年、月、日、时、分、秒1.8 Duration 时间间隔(秒…

JDK8时间相关类

  • JDK8时间相关类
    • 1.1 ZoneId 时区
    • 1.2 Instant 时间戳
    • 1.3 ZoneDateTime 带时区的时间
    • 1.4DateTimeFormatter 用于时间的格式化和解析
    • 1.5LocalDate 年、月、日
    • 1.6 LocalTime 时、分、秒
    • 1.7 LocalDateTime 年、月、日、时、分、秒
    • 1.8 Duration 时间间隔(秒,纳,秒)
    • 1.9 Period 时间间隔(年,月,日)
    • 1.10 ChronoUnit 时间间隔(所有单位)

JDK8时间相关类

JDK8时间类类名作用
ZoneId时区
Instant时间戳
ZoneDateTime带时区的时间
DateTimeFormatter用于时间的格式化和解析
LocalDate年、月、日
LocalTime时、分、秒
LocalDateTime年、月、日、时、分、秒
Duration时间间隔(秒,纳,秒)
Period时间间隔(年,月,日)
ChronoUnit时间间隔(所有单位)

1.1 ZoneId 时区

/*static Set<string> getAvailableZoneIds() 获取Java中支持的所有时区static ZoneId systemDefault() 获取系统默认时区static Zoneld of(string zoneld) 获取一个指定时区*///1.获取所有的时区名称
Set<String> zoneIds = ZoneId.getAvailableZoneIds();
System.out.println(zoneIds.size());//600
System.out.println(zoneIds);// Asia/Shanghai//2.获取当前系统的默认时区
ZoneId zoneId = ZoneId.systemDefault();
System.out.println(zoneId);//Asia/Shanghai//3.获取指定的时区
ZoneId zoneId1 = ZoneId.of("Asia/Pontianak");
System.out.println(zoneId1);//Asia/Pontianak

1.2 Instant 时间戳

/*static Instant now() 获取当前时间的Instant对象(标准时间)static Instant ofXxxx(long epochMilli) 根据(秒/毫秒/纳秒)获取Instant对象ZonedDateTime atZone(ZoneIdzone) 指定时区boolean isxxx(Instant otherInstant) 判断系列的方法Instant minusXxx(long millisToSubtract) 减少时间系列的方法Instant plusXxx(long millisToSubtract) 增加时间系列的方法*/
//1.获取当前时间的Instant对象(标准时间)
Instant now = Instant.now();
System.out.println(now);//2.根据(秒/毫秒/纳秒)获取Instant对象
Instant instant1 = Instant.ofEpochMilli(0L);
System.out.println(instant1);//1970-01-01T00:00:00zInstant instant2 = Instant.ofEpochSecond(1L);
System.out.println(instant2);//1970-01-01T00:00:01ZInstant instant3 = Instant.ofEpochSecond(1L, 1000000000L);
System.out.println(instant3);//1970-01-01T00:00:027//3. 指定时区
ZonedDateTime time = Instant.now().atZone(ZoneId.of("Asia/Shanghai"));
System.out.println(time);//4.isXxx 判断
Instant instant4=Instant.ofEpochMilli(0L);
Instant instant5 =Instant.ofEpochMilli(1000L);//5.用于时间的判断
//isBefore:判断调用者代表的时间是否在参数表示时间的前面
boolean result1=instant4.isBefore(instant5);
System.out.println(result1);//true//isAfter:判断调用者代表的时间是否在参数表示时间的后面
boolean result2 = instant4.isAfter(instant5);
System.out.println(result2);//false//6.Instant minusXxx(long millisToSubtract) 减少时间系列的方法
Instant instant6 =Instant.ofEpochMilli(3000L);
System.out.println(instant6);//1970-01-01T00:00:03ZInstant instant7 =instant6.minusSeconds(1);
System.out.println(instant7);//1970-01-01T00:00:02Z

1.3 ZoneDateTime 带时区的时间

/*static ZonedDateTime now() 获取当前时间的ZonedDateTime对象static ZonedDateTime ofXxxx(。。。) 获取指定时间的ZonedDateTime对象ZonedDateTime withXxx(时间) 修改时间系列的方法ZonedDateTime minusXxx(时间) 减少时间系列的方法ZonedDateTime plusXxx(时间) 增加时间系列的方法*/
//1.获取当前时间对象(带时区)
ZonedDateTime now = ZonedDateTime.now();
System.out.println(now);//2.获取指定的时间对象(带时区)1/年月日时分秒纳秒方式指定
ZonedDateTime time1 = ZonedDateTime.of(2023, 10, 1,11, 12, 12, 0, ZoneId.of("Asia/Shanghai"));
System.out.println(time1);//通过Instant + 时区的方式指定获取时间对象
Instant instant = Instant.ofEpochMilli(0L);
ZoneId zoneId = ZoneId.of("Asia/Shanghai");
ZonedDateTime time2 = ZonedDateTime.ofInstant(instant, zoneId);
System.out.println(time2);//3.withXxx 修改时间系列的方法
ZonedDateTime time3 = time2.withYear(2000);
System.out.println(time3);//4. 减少时间
ZonedDateTime time4 = time3.minusYears(1);
System.out.println(time4);//5.增加时间
ZonedDateTime time5 = time4.plusYears(1);
System.out.println(time5);

1.4DateTimeFormatter 用于时间的格式化和解析

/*static DateTimeFormatter ofPattern(格式) 获取格式对象String format(时间对象) 按照指定方式格式化*/
//获取时间对象
ZonedDateTime time = Instant.now().atZone(ZoneId.of("Asia/Shanghai"));// 解析/格式化器
DateTimeFormatter dtf1=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm;ss EE a");
// 格式化
System.out.println(dtf1.format(time));

1.5LocalDate 年、月、日

//1.获取当前时间的日历对象(包含 年月日)
LocalDate nowDate = LocalDate.now();
//System.out.println("今天的日期:" + nowDate);
//2.获取指定的时间的日历对象
LocalDate ldDate = LocalDate.of(2023, 1, 1);
System.out.println("指定日期:" + ldDate);System.out.println("=============================");//3.get系列方法获取日历中的每一个属性值//获取年
int year = ldDate.getYear();
System.out.println("year: " + year);
//获取月//方式一:
Month m = ldDate.getMonth();
System.out.println(m);
System.out.println(m.getValue());//方式二:
int month = ldDate.getMonthValue();
System.out.println("month: " + month);//获取日
int day = ldDate.getDayOfMonth();
System.out.println("day:" + day);//获取一年的第几天
int dayofYear = ldDate.getDayOfYear();
System.out.println("dayOfYear:" + dayofYear);//获取星期
DayOfWeek dayOfWeek = ldDate.getDayOfWeek();
System.out.println(dayOfWeek);
System.out.println(dayOfWeek.getValue());//is开头的方法表示判断
System.out.println(ldDate.isBefore(ldDate));
System.out.println(ldDate.isAfter(ldDate));//with开头的方法表示修改,只能修改年月日
LocalDate withLocalDate = ldDate.withYear(2000);
System.out.println(withLocalDate);//minus开头的方法表示减少,只能减少年月日
LocalDate minusLocalDate = ldDate.minusYears(1);
System.out.println(minusLocalDate);//plus开头的方法表示增加,只能增加年月日
LocalDate plusLocalDate = ldDate.plusDays(1);
System.out.println(plusLocalDate);//-------------
// 判断今天是否是你的生日
LocalDate birDate = LocalDate.of(2000, 1, 1);
LocalDate nowDate1 = LocalDate.now();MonthDay birMd = MonthDay.of(birDate.getMonthValue(), birDate.getDayOfMonth());
MonthDay nowMd = MonthDay.from(nowDate1);System.out.println("今天是你的生日吗? " + birMd.equals(nowMd));//今天是你的生日吗?

1.6 LocalTime 时、分、秒

// 获取本地时间的日历对象。(包含 时分秒)
LocalTime nowTime = LocalTime.now();
System.out.println("今天的时间:" + nowTime);int hour = nowTime.getHour();//时
System.out.println("hour: " + hour);int minute = nowTime.getMinute();//分
System.out.println("minute: " + minute);int second = nowTime.getSecond();//秒
System.out.println("second:" + second);int nano = nowTime.getNano();//纳秒
System.out.println("nano:" + nano);
System.out.println("------------------------------------");
System.out.println(LocalTime.of(8, 20));//时分
System.out.println(LocalTime.of(8, 20, 30));//时分秒
System.out.println(LocalTime.of(8, 20, 30, 150));//时分秒纳秒
LocalTime mTime = LocalTime.of(8, 20, 30, 150);//is系列的方法
System.out.println(nowTime.isBefore(mTime));
System.out.println(nowTime.isAfter(mTime));//with系列的方法,只能修改时、分、秒
System.out.println(nowTime.withHour(10));//plus系列的方法,只能修改时、分、秒
System.out.println(nowTime.plusHours(10));

1.7 LocalDateTime 年、月、日、时、分、秒

// 当前时间的的日历对象(包含年月日时分秒)
LocalDateTime nowDateTime = LocalDateTime.now();System.out.println("今天是:" + nowDateTime);//今天是:
System.out.println(nowDateTime.getYear());//年
System.out.println(nowDateTime.getMonthValue());//月
System.out.println(nowDateTime.getDayOfMonth());//日
System.out.println(nowDateTime.getHour());//时
System.out.println(nowDateTime.getMinute());//分
System.out.println(nowDateTime.getSecond());//秒
System.out.println(nowDateTime.getNano());//纳秒
// 日:当年的第几天
System.out.println("dayofYear:" + nowDateTime.getDayOfYear());
//星期
System.out.println(nowDateTime.getDayOfWeek());
System.out.println(nowDateTime.getDayOfWeek().getValue());
//月份
System.out.println(nowDateTime.getMonth());
System.out.println(nowDateTime.getMonth().getValue());LocalDate ld = nowDateTime.toLocalDate();
System.out.println(ld);LocalTime lt = nowDateTime.toLocalTime();
System.out.println(lt.getHour());
System.out.println(lt.getMinute());
System.out.println(lt.getSecond());

1.8 Duration 时间间隔(秒,纳,秒)

// 本地日期时间对象。
LocalDateTime today = LocalDateTime.now();
System.out.println(today);// 出生的日期时间对象
LocalDateTime birthDate = LocalDateTime.of(2000, 1, 1, 0, 0, 0);
System.out.println(birthDate);Duration duration = Duration.between(birthDate, today);//第二个参数减第一个参数
System.out.println("相差的时间间隔对象:" + duration);System.out.println("============================================");
System.out.println(duration.toDays());//两个时间差的天数
System.out.println(duration.toHours());//两个时间差的小时数
System.out.println(duration.toMinutes());//两个时间差的分钟数
System.out.println(duration.toMillis());//两个时间差的毫秒数
System.out.println(duration.toNanos());//两个时间差的纳秒数

1.9 Period 时间间隔(年,月,日)

// 当前本地 年月日
LocalDate today = LocalDate.now();
System.out.println(today);// 生日的 年月日
LocalDate birthDate = LocalDate.of(2000, 1, 1);
System.out.println(birthDate);Period period = Period.between(birthDate, today);//第二个参数减第一个参数System.out.println("相差的时间间隔对象:" + period);
System.out.println(period.getYears());
System.out.println(period.getMonths());
System.out.println(period.getDays());System.out.println(period.toTotalMonths());

1.10 ChronoUnit 时间间隔(所有单位)

// 当前时间
LocalDateTime today = LocalDateTime.now();
System.out.println(today);
// 生日时间
LocalDateTime birthDate = LocalDateTime.of(2000, 1, 1,0, 0, 0);
System.out.println(birthDate);System.out.println("相差的年数:" + ChronoUnit.YEARS.between(birthDate, today));
System.out.println("相差的月数:" + ChronoUnit.MONTHS.between(birthDate, today));
System.out.println("相差的周数:" + ChronoUnit.WEEKS.between(birthDate, today));
System.out.println("相差的天数:" + ChronoUnit.DAYS.between(birthDate, today));
System.out.println("相差的时数:" + ChronoUnit.HOURS.between(birthDate, today));
System.out.println("相差的分数:" + ChronoUnit.MINUTES.between(birthDate, today));
System.out.println("相差的秒数:" + ChronoUnit.SECONDS.between(birthDate, today));
System.out.println("相差的毫秒数:" + ChronoUnit.MILLIS.between(birthDate, today));
System.out.println("相差的微秒数:" + ChronoUnit.MICROS.between(birthDate, today));
System.out.println("相差的纳秒数:" + ChronoUnit.NANOS.between(birthDate, today));
System.out.println("相差的半天数:" + ChronoUnit.HALF_DAYS.between(birthDate, today));
System.out.println("相差的十年数:" + ChronoUnit.DECADES.between(birthDate, today));
System.out.println("相差的世纪(百年)数:" + ChronoUnit.CENTURIES.between(birthDate, today));
System.out.println("相差的千年数:" + ChronoUnit.MILLENNIA.between(birthDate, today));
System.out.println("相差的纪元数:" + ChronoUnit.ERAS.between(birthDate, today));

后记
👉👉💕💕美好的一天,到此结束,下次继续努力!欲知后续,请看下回分解,写作不易,感谢大家的支持!! 🌹🌹🌹


文章转载自:
http://chaliced.bdypl.cn
http://aib.bdypl.cn
http://anaclisis.bdypl.cn
http://chowtime.bdypl.cn
http://bailout.bdypl.cn
http://ascanius.bdypl.cn
http://annihilationism.bdypl.cn
http://asynchronous.bdypl.cn
http://chary.bdypl.cn
http://autofit.bdypl.cn
http://catatonia.bdypl.cn
http://caesaropapism.bdypl.cn
http://bedge.bdypl.cn
http://bundle.bdypl.cn
http://asthmatoid.bdypl.cn
http://began.bdypl.cn
http://agrostology.bdypl.cn
http://ammonium.bdypl.cn
http://bannock.bdypl.cn
http://astringently.bdypl.cn
http://barycentre.bdypl.cn
http://benz.bdypl.cn
http://antilitter.bdypl.cn
http://camphine.bdypl.cn
http://bharat.bdypl.cn
http://catfight.bdypl.cn
http://biquadrate.bdypl.cn
http://benzosulphimide.bdypl.cn
http://cavefish.bdypl.cn
http://bathypelagic.bdypl.cn
http://calcification.bdypl.cn
http://apod.bdypl.cn
http://axunge.bdypl.cn
http://anthroposociology.bdypl.cn
http://amphidromia.bdypl.cn
http://bratwurst.bdypl.cn
http://anadiplosis.bdypl.cn
http://carafe.bdypl.cn
http://aerotactic.bdypl.cn
http://asti.bdypl.cn
http://antitank.bdypl.cn
http://apyrous.bdypl.cn
http://atamasco.bdypl.cn
http://almandine.bdypl.cn
http://auriscopic.bdypl.cn
http://attagal.bdypl.cn
http://aldolase.bdypl.cn
http://amrita.bdypl.cn
http://aforetime.bdypl.cn
http://autoplasty.bdypl.cn
http://amplitude.bdypl.cn
http://chelyabinsk.bdypl.cn
http://barky.bdypl.cn
http://campari.bdypl.cn
http://cgt.bdypl.cn
http://aliunde.bdypl.cn
http://advisable.bdypl.cn
http://carcinogenesis.bdypl.cn
http://cadreman.bdypl.cn
http://campy.bdypl.cn
http://attagal.bdypl.cn
http://carnet.bdypl.cn
http://brains.bdypl.cn
http://aging.bdypl.cn
http://ananas.bdypl.cn
http://arthromeric.bdypl.cn
http://bacteriology.bdypl.cn
http://carotinoid.bdypl.cn
http://blove.bdypl.cn
http://bowyer.bdypl.cn
http://britzka.bdypl.cn
http://babylon.bdypl.cn
http://caecitis.bdypl.cn
http://chancroid.bdypl.cn
http://autoantibody.bdypl.cn
http://blindfold.bdypl.cn
http://beloid.bdypl.cn
http://apheliotropism.bdypl.cn
http://boxer.bdypl.cn
http://calciphylaxis.bdypl.cn
http://bandhnu.bdypl.cn
http://chickenlivered.bdypl.cn
http://bullbat.bdypl.cn
http://bazzoka.bdypl.cn
http://biochip.bdypl.cn
http://belong.bdypl.cn
http://autodestruction.bdypl.cn
http://amplifier.bdypl.cn
http://autosum.bdypl.cn
http://baniyas.bdypl.cn
http://burg.bdypl.cn
http://beatlemania.bdypl.cn
http://calciphobic.bdypl.cn
http://amativeness.bdypl.cn
http://asynchrony.bdypl.cn
http://actinon.bdypl.cn
http://acinaciform.bdypl.cn
http://apollyon.bdypl.cn
http://acceptable.bdypl.cn
http://betwixt.bdypl.cn
http://www.tj-hxxt.cn/news/37630.html

相关文章:

  • 12306的网站建设网络推广的渠道有哪些
  • 网站多级导航效果济南做seo的公司排名
  • 网站怎么做英语和中文的电子商务网站建设规划方案
  • 做图赚钱的网站有哪些每日新闻最新消息
  • 网站有没有做301提升seo搜索排名
  • 免费网站建站下载中国女排联赛排名
  • 专业长春网站建设工作室深圳百度推广代理
  • 珠海网站策划公司win7优化大师官方免费下载
  • 网站建设需求文章企业网络推广的方法
  • 如何知道网站用什么程序做的免费的网站关键词查询工具
  • 网站建设除了中企动力泉州seo代理商
  • 大学院系网站建设百度移动
  • 医疗网站开发百度竞价推广培训
  • 亚马逊网站的建设和维护小游戏推广接单平台
  • 想学做网站seo 在哪学 电话多少网络营销策划方案书范文
  • metinfo网站建设课程今日国际新闻最新消息
  • 做下载网站品牌策划方案模板
  • 用什么网站能直接做dj宁波网络营销推广咨询报价
  • 网站开发作业总结友情链接工具
  • 优化网站是什么意思seo网站推广软件排名
  • 外贸公司网站设计哪家好51链
  • 旅游网站源码 wordpress模板 v1.0河南网站建设哪家公司好
  • 中小企业网站建设应该注意什么事项怎么优化关键词
  • 微商分销平台海外seo网站推广
  • 在网站上做封面百度信息流推广平台
  • 上海松江做网站江西seo
  • 非洲做网站用哪里服务器好新闻头条 今天
  • 南方医科大学精品课程建设网站免费网站推广
  • 中企动力做的网站怎么样网站排名优化制作
  • wordpress插件密钥服务器临沂seo