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

中山网站建设公司seo优化网络公司排名

中山网站建设公司,seo优化网络公司排名,专业网站建设商家,仿淘宝php c2c电子商务网站模板如何把String/Date转成LocalDateTime参考String、Date与LocalDate、LocalTime、LocalDateTime之间互转 String、Date、LocalDateTime、Calendar与时间戳之间互相转化参考String、Date、LocalDateTime、Calendar与时间戳之间互相转化 方法介绍 withYear(int year) 指定日期的…

如何把String/Date转成LocalDateTime参考String、Date与LocalDate、LocalTime、LocalDateTime之间互转

String、Date、LocalDateTime、Calendar与时间戳之间互相转化参考String、Date、LocalDateTime、Calendar与时间戳之间互相转化

方法介绍

withYear(int year) 指定日期的年
withMonth(int month) 指定日期的月 范围:1-12
withDayOfMonth(int dayOfMonth) 指定日期是月中的第几天 范围:1 - 28/31
withDayOfYear(int dayOfYear) 指定日期是年中的第几天 范围:1 - 365/366
withHour(int hour) 指定日期的小时 范围:0 - 23
withMinute(int minute) 指定日期的分钟 范围:0 - 59
withSecond(int second) 指定日期的秒 范围:0 - 59
withNano(int nanoOfSecond) 指定日期中纳秒

具体使用

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;/*** 测试LocalDate* @author leishen*/
public class LocalDateTest {/*** LOCAL_DATE_TIME的时间格式*/private static final DateTimeFormatter LOCAL_DATE_TIME=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss ms ns");/*** DATE_TIME的时间格式*/private static final SimpleDateFormat DATE_TIME=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ms");public static void main(String[] args) {//系统默认时区ZoneId zoneId = ZoneId.systemDefault();//Date-->ZonedDateTimeZonedDateTime zonedDateTime = new Date().toInstant().atZone(zoneId);LocalDateTime localDateTime = zonedDateTime.toLocalDateTime();System.out.println("localDateTime.format(LOCAL_DATE_TIME) = " + localDateTime.format(LOCAL_DATE_TIME));//withYear(int year) 指定日期的年localDateTime = localDateTime.withYear(2022);System.out.println("localDateTime.withYear(2022) = " +localDateTime.format(LOCAL_DATE_TIME));//withMonth(int month) 指定日期的月 范围:1-12localDateTime = localDateTime.withMonth(1);System.out.println("localDateTime.withMonth(1) = " + localDateTime.format(LOCAL_DATE_TIME));//withDayOfMonth(int dayOfMonth) 指定日期是月中的第几天 范围:1 - 28/31localDateTime = localDateTime.withDayOfMonth(1);System.out.println("localDateTime.withDayOfMonth(1) = " + localDateTime.format(LOCAL_DATE_TIME));//withDayOfYear(int dayOfYear) 指定日期是年中的第几天 范围:1 - 365/366localDateTime = localDateTime.withDayOfYear(60);System.out.println("localDateTime.withDayOfYear(60) = " + localDateTime.format(LOCAL_DATE_TIME));//withHour(int hour) 指定日期的小时 范围:0 - 23localDateTime = localDateTime.withHour(23);System.out.println("localDateTime.withHour(23) = " + localDateTime.format(LOCAL_DATE_TIME));//withMinute(int minute) 指定日期的分钟 范围:0 - 59localDateTime = localDateTime.withMinute(59);System.out.println("localDateTime.withMinute(59) = " + localDateTime.format(LOCAL_DATE_TIME));//withSecond(int second) 指定日期的秒 范围:0 - 59localDateTime =localDateTime.withSecond(59);System.out.println("localDateTime.withSecond(59) = " + localDateTime.format(LOCAL_DATE_TIME));//withNano(int nanoOfSecond) 指定日期中纳秒localDateTime = localDateTime.withNano(0);System.out.println("localDateTime.withNano(0) = " + localDateTime.format(LOCAL_DATE_TIME));Date date = Date.from(localDateTime.atZone(zoneId).toInstant());System.out.println("DATE_TIME.format(date) = " + DATE_TIME.format(date));}
}
http://www.hengruixuexiao.com/news/42771.html

相关文章:

  • 网站域名跳转怎么做郑州seo优化培训
  • 做外贸的怎样才能上国外网站seo搜索优化待遇
  • 平台和网站有什么区别长春百度推广电话
  • 零售网站制作河南省最新通知
  • 信宜网站建设公司站外推广怎么做
  • 安全联盟这种网站建设内存优化大师
  • 深圳集团网站开发福州今日头条新闻
  • 网络设计课程设计前言优化设计单元测试卷答案
  • 加强政府网站信息内容建设十大免费最亏的免费app
  • 个人适合建什么网站免费的关键词优化软件
  • 网站交互怎么做网站站点查询
  • 网站方案书学新媒体运营最好的培训学校
  • 广州网站平台怎么做凡科建站登录
  • wordpress媒体优化宁波关键词优化平台
  • 哪家做网站比较好百度目前的推广方法
  • 做网站开发需要培训吗网站模板价格
  • 网站备案备注信息免费做网站网站的软件
  • 西部数码网站管理助手4.0 教程百度竞价开户渠道
  • 能自己做的ppt网站朋友圈产品推广文案
  • 网站游戏入口百度指数是什么
  • 龙岩做网站开发哪家做的好免费的编程自学网站
  • 购物网站建设与开发软件开发网站
  • 找人做网站 自己购买服务器付费推广方式有哪些
  • 保定网站制作哪家好建设百度推广seo优化
  • 东莞网站建设 旅游2022年五月份热点事件
  • 网站平台建设咨询合同成人英语培训
  • 网站开发文档word百度云搜索资源入口
  • 可以自建网站吗宁波网站优化公司推荐
  • 网页制作的方法成都seo优化推广
  • 网站首页html代码的标签百度指数官网