java_DateTimeFormatter
日期时间的格式化和解析:
public class DateTimeFormatterTest { /** * 时间日期格式化 * @param args */ public static void main(String[] args) { LocalDateTime localDateTime = LocalDateTime.now(); //方式一2019-07-04T10:27:28.453 DateTimeFormatter isoLocalDateTime = DateTimeFormatter.ISO_LOCAL_DATE_TIME; String format = isoLocalDateTime.format(localDateTime); System.out.println(format); //方式二 // SHORT:19-7-4 上午10:42 // LONG:2019年7月4日 上午10时43分35秒 // MEDIUM:2019-7-4 10:44:11 DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM); String format1 = formatter.format(localDateTime); System.out.println(format1); //方式三 // 自定义:2019-7-4 10:46:23 DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyy-MM-dd HH-mm-ss"); String format2 = formatter1.format(localDateTime); System.out.println(format2); //解析:{},ISO resolved to 2019-07-04T10:49:46 TemporalAccessor parse = formatter1.parse("2019-07-04 10-49-46"); System.out.println(parse); } }
java_DateTimeFormatter的更多相关文章
随机推荐
- ETL工具-Kattle:查询 HTTP/WebService
发送HTTP POST请求,获取返回内容. 发送HTTP GET请求,获取返回内容,可以从前面获取URL.参数名.参数值 通过Restful获取数据 通过webService获取数据 HTTP ...
- 28 利用平面对应关系求解RT空间转换矩阵
0 引言 问题背景:给定CAD模型与点云的情况下,基于CAD比对实现对实测点云的尺寸测量是三维测量技术中一种常用的思路.该思路的关键问题在于需要精确求解CAD模型与点云之间的空间转换矩阵.采用ICP( ...
- 下面是一段delphi代码,你在c# 中引入api 即可
procedure TForm1.Button1Click(Sender: TObject);var i:HWND; cs:CREATESTRUCT;begin// i := FindWindowEx ...
- NX二次开发-UFUN求两个对象最短距离UF_MODL_ask_minimum_dist
NX9+VS2012 #include <uf.h> #include <uf_modl.h> #include <uf_ui.h> UF_initialize() ...
- js的线程和同步异步以及console.log机制
项目上线了,闲下来就写写东西吧.积累了好多东西都没有做笔记~挑几个印象深刻的记录一下吧. js的同步异步以及单线程问题: 都知道单线程是js的一大特性.但是通常io(ajax获取服务器数据).用户/浏 ...
- 牛客多校第十场 B Coffee Chicken 递归
题意: 给你一个“斐波那契”字符串数列,第n项由第n-1项和第n-2项拼接而成,输出某项的某位及其后10位. 题解: 递归求解即可. #include<bits/stdc++.h> usi ...
- sqlserver中常用的windows命令行的操作
1.删除指定目录下指定时间之前的文件: ), ), @sqltxtdel varchar(max) --指定的删除时间 set @deldate= '-8' --指定的删除路径 set @bakpat ...
- ECMAScript1.1 js书写位置 | 声明变量 | 基本数据类型 | 数据类型转换 | 操作符 | 布尔类型的隐式转换
js书写位置 由于在写css样式时使用的时双引号,所以我们在写js代码时建议使用单引号(‘’)! 行内式 <input type="button" value="点 ...
- 大道浮屠诀---mysql5.7.28 for linux安装
环境: redhat6.5 MySQL Community Server 5.7.28 https://dev.mysql.com/downloads/mysql/5.7.html 安装RMP包的具体 ...
- 2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred)
2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred) easy: ACE ...