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的更多相关文章
随机推荐
- 通过jquery获取页面信息
获取浏览器显示区域(可视区域)的高度 : $(window).height(); 获取浏览器显示区域(可视区域)的宽度 :$(window).width(); 获取页面的文档高度 $(document ...
- QueryList 来做采集是什么样子
采集百度搜索结果列表的标题和链接. $data = QueryList::get('https://www.baidu.com/s?wd=QueryList') // 设置采集规则 ->rule ...
- 01二维背包+bitset优化——hdu5890
口胡一种别的解法: 三重退背包,g1[j]k]表示不选x的选了j件物品,体积为k的方案数,g[0][0] = 1 , g1[j][k]=dp[j][k]-g1[j-1][k-a[x]] 然后按这样再退 ...
- [JZOJ 5811] 简单的填数
题意:自己搜吧... 思路: 记二元组\((x,l)\)表示当前为\(x\)且之前有\(l\)个连续数与\(x\)相同. 并且维护up和low数组表示取到最大/最小值时,连续序列的长度. 正一遍,反一 ...
- iOS 点击Application icon加载推送通知Data
今天做APNS远程推送通知遇到了一个问题,就是手机接收到通知的时候,如果马上点击通知的 alert view时候,系统马上唤醒你的Application,通知或调用你的didReceiveLocalN ...
- -bash: make: command not found
yum -y install gcc automake autoconf libtool make
- 2018ICPC焦作 F. Honeycomb /// BFS
题目大意: 给定n m表示一共n行每行m个蜂巢 求从S到T的最短路径 input 1 3 4 +---+ +---+ / \ / \ + +---+ +---+ \ \ / \ + + S +---+ ...
- USACO2005 City Skyline /// oj23401
题目大意: Input * Line 1: Two space separated integers: N and W * Lines 2..N+1: Two space separated inte ...
- 中文linux安装oracle界面乱码解决方案
来自:http://blog.csdn.net/h249059945/article/details/12122853 在linux的中文操作系统下使用xmanager进行oracle进行安装的时候, ...
- Ubuntu18.04 安装搜狗拼音
参考文章:https://blog.csdn.net/fx_yzjy101/article/details/80243710 1. 安装fcitx sudo apt-get install fcitx ...