Search in sources :

Example 31 with JDateTime

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

the class JDateTimeConverterTest method testSqlTime2JDateTime.

@Test
public void testSqlTime2JDateTime() {
    Time sqltime = new Time(time);
    JDateTime jdt = jDateTimeConverter.convert(sqltime);
    assertEquals(time, jdt.getTimeInMillis());
}
Also used : JDateTime(jodd.datetime.JDateTime) JDateTime(jodd.datetime.JDateTime) Time(java.sql.Time) Test(org.junit.Test)

Example 32 with JDateTime

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

the class JDateTimeConverterTest method testCalendar2JDateTime.

@Test
public void testCalendar2JDateTime() {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(time);
    JDateTime jdt = jDateTimeConverter.convert(calendar);
    assertEquals(time, jdt.getTimeInMillis());
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) JDateTime(jodd.datetime.JDateTime) Test(org.junit.Test)

Example 33 with JDateTime

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

the class SqlTimeConverterTest method testJDateTime2Timestamp.

@Test
public void testJDateTime2Timestamp() {
    JDateTime jdt = new JDateTime(time);
    Time sqltime = sqlTimeConverter.convert(jdt);
    assertEquals(time, sqltime.getTime());
}
Also used : JDateTime(jodd.datetime.JDateTime) JDateTime(jodd.datetime.JDateTime) Time(java.sql.Time) Test(org.junit.Test)

Example 34 with JDateTime

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

the class TimeAfterConstraintTest method testIsValid.

@Test
public void testIsValid() {
    JDateTime time = new JDateTime("2011-05-01 10:11:12.344");
    TimeAfterConstraint constraint = new TimeAfterConstraint(time.clone());
    assertFalse("result must be true when validate time which is equal to constraint time", constraint.isValid(mockContext(), time.clone()));
    assertFalse("result must be false when validate time which is less than constraint time", constraint.isValid(mockContext(), time.clone().subMinute(1)));
    assertTrue("result must be true when validate time which is greater than constraint time", constraint.isValid(mockContext(), time.clone().addMinute(1)));
}
Also used : JDateTime(jodd.datetime.JDateTime) Test(org.junit.Test)

Example 35 with JDateTime

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

the class TimeBeforeConstraintTest method testConstructor2.

@Test
public void testConstructor2() {
    JDateTime time = new JDateTime();
    TimeBeforeConstraint timeBeforeConstraint = new TimeBeforeConstraint(time);
    assertEquals("time must be the same as was given to constructor", 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