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的更多相关文章
随机推荐
- HTML5布局篇
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title> ...
- 47 ubuntu指令整理学习
0 引言 在使用ubutnu时,积累了大量命令笔记.但是这些笔记比较零散,没有系统性,不便于查找和使用.通过系统性.分门别类地整理,希望可以增强对指令的记忆,提高工作效率,对ubuntu的使用更加地道 ...
- paper 15 :整理的CV代码合集
这篇blog,原来是西弗吉利亚大学的Li xin整理的,CV代码相当的全,不知道要经过多长时间的积累才会有这么丰富的资源,在此谢谢LI Xin .我现在分享给大家,希望可以共同进步!还有,我需要说一下 ...
- Kafka命令行操作
Kafka命令行操作 1)查看当前服务器中的所有topic [bingo@hadoop101 kafka]$ bin/kafka-topics.sh --list --zookeeper hadoop ...
- day27-面向对象进阶
#!/usr/bin/env python # -*- coding:utf-8 -*- # ----------------------------------------------------- ...
- 【图论】tarjan
刚接触tarjan,tarjan其实更多是用来找强联通分量.我这里呢,是看qsc的视频学的.卿学姐讲的其实很清楚啦. 我这里只是做个整理. low[]:表示能到达这个点的最小编号.[树枝边].啊,其实 ...
- LightOJ 1341 - Aladdin and the Flying Carpet
题目链接:http://lightoj.com/volume_showproblem.php?problem=1341 题意:给你地毯面积和最小可能边的长度,让你求有几种组合的可能. 题解:这题就厉害 ...
- Number浮点数运算详解
文章来自我的 github 博客,包括技术输出和学习笔记,欢迎star. 一道题 0.1 + 0.2 = ? 在浏览器中测试下计算结果,得到的结果是 0.30000000000000004,并不是理想 ...
- rem换算公式
当前rem基准值=预设的基准值/设计稿宽度*当前设备的宽度
- python的object(转)
原文章:https://www.cnblogs.com/sesshoumaru/p/6042322.html 1. object类是Python中所有类的基类,如果定义一个类时没有指定继承哪个类,则默 ...