Package java.time.format

Examples of java.time.format.DateTimeFormatter.format()


        System.out.println(d5);

        //使用DateTimeFormatter API 解析 和 格式化
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
        LocalDateTime d6 = LocalDateTime.parse("2013/12/31 23:59:59", formatter);
        System.out.println(formatter.format(d6));


        //时间获取
        System.out.println(d6.getYear());
        System.out.println(d6.getMonth());
View Full Code Here


  @Test
  public void createDateTimeFormatterWithPattern() throws Exception {
    factory = new DateTimeFormatterFactory("yyyyMMddHHmmss");
    DateTimeFormatter formatter = factory.createDateTimeFormatter();
    assertThat(formatter.format(dateTime), is("20091021121000"));
  }

  @Test
  public void createDateTimeFormatterWithNullFallback() throws Exception {
    DateTimeFormatter formatter = factory.createDateTimeFormatter(null);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.