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的更多相关文章
随机推荐
- poi之Excel下载之详细设置
1.设置标题格式 /** * HEAD样式 * * @param workbook * @param sheet */ public void setHeadCellStyles(HSSFWorkbo ...
- delphi窗体透明但上面的控件不透明怎么实现
我不知道LAZARUS是什么玩意.纯用DELPHI的话.procedure TForm1.FormCreate(Sender: TObject);var mStyle, mExStyle: Longi ...
- spark出现BINLOG_FORMAT = STATEMENT
错误解决: Caused by: java.sql.SQLException: Cannot execute statement: impossible to write to binary log ...
- NX文件名与工程图名自动关联
1.先去D:\Program Files\Siemens\NX 9.0\LOCALIZATION\prc\simpl_chinese\startup里,把默认的图框模板替换成自己定制好的模板,如何替换 ...
- C++从string中删除所有的某个特定字符【转载】
转载自https://www.cnblogs.com/7z7chn/p/6341453.html C++中要从string中删除所有某个特定字符, 可用如下代码 str.erase(std::remo ...
- Unity UGUI和特效(含粒子系统和3D Object)之间层级问题
撰写本文时使用Unity的版本为2017.4.10f1(64bit) 1.描述问题 需求:通过UGUI制作一个界面之后,我需要在界面的后面跟前面各添加一个特效. 问题:同一层级UI是最后渲染的,所以U ...
- kma 2019CSP前刷题记录
2019/10/25 \([LNOI2014]\ LCA\) \([Luogu\ P2774]\) 方格取数问题 \(Gauss\)消元板 \([JSOI2008]\)球形空间产生器 2019/10/ ...
- DLL劫持技术例子: HijackDll
控制台程序:DllLoader Dll加载器,用于动态加载目标Dll,并动态调用目标函数 #include <cstdio> #include <windows.h> type ...
- ionic:创建 APP
ylbtech-ionic:创建 APP 1.返回顶部 1. ionic 创建 APP 前面的章节中我们已经学会了 ionic 框架如何导入到项目中. 接下来我们将为大家介绍如何创建一个 ionic ...
- 学习k8s的经验
最近在学k8s,总结一下安装k8s的坑. 1.晚上关于k8s的学习资料很多,多不如精,这个博客很好,https://blog.csdn.net/sinat_35930259/article/categ ...