Date以及LocalDateTime格式化
public static void main(String[] args) {
LocalDateTime local = LocalDateTime.now();
Date date = new Date();
//Date 类型的时间使用SimpleDateFormat
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.format(date));
//LocalDateTime 类型的使用DateTimeFormatter
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
System.out.println(formatter.format(local));
}
Date以及LocalDateTime格式化的更多相关文章
- Java基础进阶:时间类要点摘要,时间Date类实现格式化与解析源码实现详解,LocalDateTime时间类格式化与解析源码实现详解,Period,Duration获取时间间隔与源码实现,程序异常解析与处理方式
要点摘要 课堂笔记 日期相关 JDK7 日期类-Date 概述 表示一个时间点对象,这个时间点是以1970年1月1日为参考点; 作用 可以通过该类的对象,表示一个时间,并面向对象操作时间; 构造方法 ...
- Java8 LocalDateTime获取时间戳(毫秒/秒)、LocalDateTime与String互转、Date与LocalDateTime互转
本文目前提供:LocalDateTime获取时间戳(毫秒/秒).LocalDateTime与String互转.Date与LocalDateTime互转 文中都使用的时区都是东8区,也就是北京时间.这是 ...
- Java8中 Date和LocalDateTime的相互转换
一.在Java 8中将Date转换为LocalDateTime 方法1: 将Date转换为LocalDatetime,我们可以使用以下方法: 1.从日期获取ZonedDateTime并使用其方法toL ...
- Date转换为LocalDateTime
一.在Java 8中将Date转换为LocalDateTime 方法1: 将Date转换为LocalDatetime,我们可以使用以下方法: 1.从日期获取ZonedDateTime并使用其方法toL ...
- Java日期时间API系列13-----Jdk8中java.time包中的新的日期时间API类,时间类转换,Date转LocalDateTime,LocalDateTime转Date等
从前面的系列博客中可以看出Jdk8中java.time包中的新的日期时间API类设计的很好,但Date由于使用仍非常广泛,这就涉及到Date转LocalDateTime,LocalDateTime转D ...
- springmvc:jsp fmt标签格式化Date时间,格式化后可以用于页面展示
java后台的对象时间参数是date类型,在前端想格式化,又是放在input输入框中的 先引入jstl标签库 <%@taglib uri="http://java.sun.com/js ...
- Linux下date命令,格式化输出,时间设置
date命令的帮助信息 [root@localhost source]# date --help用法:date [选项]... [+格式] 或:date [-u|--utc|--universal] ...
- Convert Date between LocalDateTime
http://blog.progs.be/542/date-to-java-time Java8 has new date and time classes to “replace” the old ...
- 【转】Date类学习总结(Calendar Date 字符串 相互转换 格式化)
原文网址:http://www.blogjava.net/jerry-zhaoj/archive/2008/10/08/233228.html Date类学习总结 1.计算某一月份的最大天数 Cale ...
随机推荐
- IT从业者不可不知的三条定律
信息技术行业,也就是我们所说的IT行业,有着传统行业所未有的发展速度和模式,当然也有着它独特的发展定律.如果你是从事相关行业,下面讲到的三条定律,不可不知. 摩尔定律 比尔·盖茨曾跟通用公司老板说:如 ...
- IPy过滤
#coding=utf-8 from IPy import IP write=open('result.txt','a') allgame=open('allgame.txt') gameline=a ...
- hive creating temporary folder on: Error encountered near token 'TOK_TMP_FILE'
执行create tmp.tablename as select .....语句的时候报以下错误: SemanticException 0:0 creating temporary folder o ...
- crm-4权限
1.rbac-优化login函数 因为login是业务逻辑 ,而rbac是个组件 ,将rbac在login的代码分离 ###初始化权限函数分离出去 rbac/service/permission fr ...
- 关于Spring Boot你不得不知道的事--Spring Boot的基本操作
1 Pom文件 1.1 spring-boot-starter-parent 表示当前pom文件从spring-boot-starter-parent继承下来,在spring-boot-starter ...
- Typescript基础(2)——函数
前言 今天继续typescript的学习,开始函数的学习. 函数 函数的定义 和JavaScript一样,TypeScript函数可以创建有名字的函数和匿名函数. 你可以随意选择适合应用程序的方式,不 ...
- centos7 apache后台转nginx后台
背景 一开始买完服务器装的是用apache搭的后台, 现在想使用nginx, 希望对你有参考作用 查看系统版本信息 lsb_release -a 我的版本信息是 首先关闭apache-tomcat服务 ...
- 如何用charles进行https抓包
版权声明:本文为xing_star原创文章,转载请注明出处! 本文同步自http://javaexception.com/archives/138 如何用charles进行https抓包 晚上在家鼓捣 ...
- 如何优雅地停止Spark Streaming Job
由于streaming流程序一旦运行起来,基本上是无休止的状态,除非是特殊情况,否则是不会停的.因为每时每刻都有可能在处理数据,如果要停止也需要确认当前正在处理的数据执行完毕,并且不能再接受新的数据, ...
- java实现序列化的两种方式
1.Serializable接口 2.Externalizable接口 public class Demo2 implements Externalizable{ transient private ...