Search in sources :

Example 16 with JDateTime

use of jodd.datetime.JDateTime in project jodd by oblac.

the class ParserTest method testParseWithoutDelimiters.

@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);
}
Also used : DateTimeStamp(jodd.datetime.DateTimeStamp) JDateTime(jodd.datetime.JDateTime) Test(org.junit.Test)

Example 17 with JDateTime

use of jodd.datetime.JDateTime in project jodd by oblac.

the class TimeAfterConstraintTest method testSetTime.

@Test
public void testSetTime() {
    TimeAfterConstraint timeAfterConstraint = new TimeAfterConstraint();
    JDateTime time = new JDateTime();
    timeAfterConstraint.setTime(time);
    assertEquals("method must return the same time as was given to set method", timeAfterConstraint.getTime(), time);
}
Also used : JDateTime(jodd.datetime.JDateTime) Test(org.junit.Test)

Example 18 with JDateTime

use of jodd.datetime.JDateTime in project jodd by oblac.

the class TimeAfterConstraintTest method testConfigure.

@Test
public void testConfigure() {
    TimeAfterConstraint timeAfterConstraint = new TimeAfterConstraint();
    JDateTime time = new JDateTime();
    TimeAfter annotation = mock(TimeAfter.class);
    stub(annotation.value()).toReturn(JDateTimeDefault.formatter.convert(time, JDateTimeDefault.format));
    timeAfterConstraint.configure(annotation);
    assertEquals("method must return the same time as was set to annotation when configure", timeAfterConstraint.getTime(), time);
}
Also used : JDateTime(jodd.datetime.JDateTime) Test(org.junit.Test)

Example 19 with JDateTime

use of jodd.datetime.JDateTime in project jodd by oblac.

the class TimeAfterConstraintTest method testConstructor2.

@Test
public void testConstructor2() {
    JDateTime time = new JDateTime();
    TimeAfterConstraint timeAfterConstraint = new TimeAfterConstraint(time);
    assertEquals("time must be the same as was given to constructor", timeAfterConstraint.getTime(), time);
}
Also used : JDateTime(jodd.datetime.JDateTime) Test(org.junit.Test)

Example 20 with JDateTime

use of jodd.datetime.JDateTime in project jodd by oblac.

the class TimeBeforeConstraintTest method testConfigure.

@Test
public void testConfigure() {
    TimeBeforeConstraint timeBeforeConstraint = new TimeBeforeConstraint();
    JDateTime time = new JDateTime();
    timeBeforeConstraint.setTime(time);
    TimeBefore annotation = mock(TimeBefore.class);
    stub(annotation.value()).toReturn(JDateTimeDefault.formatter.convert(time, JDateTimeDefault.format));
    timeBeforeConstraint.configure(annotation);
    assertEquals("method must return the same time as was set to annotation when configure", timeBeforeConstraint.getTime(), time);
}
Also used : JDateTime(jodd.datetime.JDateTime) Test(org.junit.Test)

Aggregations

JDateTime (jodd.datetime.JDateTime)38 Test (org.junit.Test)28 Calendar (java.util.Calendar)10 GregorianCalendar (java.util.GregorianCalendar)8 Date (java.util.Date)6 Timestamp (java.sql.Timestamp)5 BigDecimal (java.math.BigDecimal)3 BigInteger (java.math.BigInteger)2 Time (java.sql.Time)2 DbSession (jodd.db.DbSession)2 CellReference (org.apache.poi.hssf.util.CellReference)2 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)2 File (java.io.File)1 Date (java.sql.Date)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 DateTimeStamp (jodd.datetime.DateTimeStamp)1 DbThreadSession (jodd.db.DbThreadSession)1 Area (jodd.json.model.cat.Area)1 Event (jodd.json.model.cat.Event)1