Package jodd.datetime.format

Source Code of jodd.datetime.format.ParserTest

// Copyright (c) 2003-2014, Jodd Team (jodd.org). All Rights Reserved.

package jodd.datetime.format;

import jodd.datetime.DateTimeStamp;
import jodd.datetime.JDateTime;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class ParserTest {

  @Test
  public void testParseWithDelimiters() {
    Iso8601JdtFormatter formatter = new Iso8601JdtFormatter();

    DateTimeStamp dateTimeStamp = formatter.parse("1234-11-12", "YYYY-MM-DD");
    assertEquals(new DateTimeStamp(1234, 11, 12), dateTimeStamp);
  }

  @Test
  public void testParseWithoutDelimiters() {
    Iso8601JdtFormatter formatter = new Iso8601JdtFormatter();

    DateTimeStamp dateTimeStamp = formatter.parse("12341112", "YYYYMMDD");
    assertEquals(new DateTimeStamp(1234, 11, 12), dateTimeStamp);


    String timePattern = "YYYYMMDDhhmmssmss";

    JDateTime jdt = new JDateTime();

    String format = jdt.toString(timePattern);

    JDateTime jdt1 = new JDateTime();

    jdt1.parse(format, timePattern);

    assertEquals(jdt, jdt1);

  }
}
TOP

Related Classes of jodd.datetime.format.ParserTest

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.