use of jodd.datetime.JDateTime in project jodd by oblac.
the class CalendarConverterTest method testJDateTime2Calendar.
@Test
public void testJDateTime2Calendar() {
JDateTime jdt = new JDateTime(time);
Calendar calendar = calendarConverter.convert(jdt);
assertEquals(time, calendar.getTimeInMillis());
}
use of jodd.datetime.JDateTime in project jodd by oblac.
the class CalendarConverterTest method testCalendarDate.
@Test
public void testCalendarDate() {
JDateTime jdt = new JDateTime();
CalendarConverter calendarConverter = new CalendarConverter();
Calendar gc = calendarConverter.convert(jdt);
DateFormat df = new SimpleDateFormat();
assertEquals(df.format(gc.getTime()), df.format(Convert.toDate(jdt)));
}
use of jodd.datetime.JDateTime in project jodd by oblac.
the class ConvertTest method testAllConversions.
@Test
public void testAllConversions() {
assertEquals(new BigDecimal("11.2"), Convert.toBigDecimal("11.2"));
assertNull(Convert.toBigDecimal(null));
assertEquals(new BigInteger("123456789"), Convert.toBigInteger("123456789"));
assertEquals(Boolean.TRUE, Convert.toBoolean(("true")));
assertEquals(true, Convert.toBooleanValue("true", false));
assertEquals(false, Convert.toBooleanValue(null, false));
assertEquals(true, Convert.toBooleanValue("true"));
assertEquals(false, Convert.toBooleanValue(null));
assertNotNull(Convert.toCalendar((new JDateTime())));
assertEquals(Character.valueOf('A'), Convert.toCharacter("A"));
assertEquals('A', Convert.toCharValue("A", ' '));
assertEquals('A', Convert.toCharValue("A"));
assertEquals(Integer.class, Convert.toClass("java.lang.Integer"));
assertEquals(Integer.class, Convert.toClassArray("java.lang.Integer")[0]);
assertEquals(1, Convert.toClassArray("java.lang.Integer").length);
assertNotNull(Convert.toDate(new JDateTime()));
assertEquals(173, Convert.toIntValue("173"));
assertEquals(173, Convert.toLongValue("173"));
assertEquals(173, Convert.toShortValue("173"));
assertEquals(17, Convert.toByteValue("17"));
assertEquals(1.0d, Convert.toDouble("1").doubleValue(), 0.005);
assertEquals(1.0d, Convert.toDoubleValue("1", 0), 0.005);
assertEquals(1.0d, Convert.toDoubleValue("1"), 0.005);
assertEquals(1.0f, Convert.toFloat("1").floatValue(), 0.005);
assertEquals(1.0f, Convert.toFloatValue("1", 0), 0.005);
assertEquals(1.0f, Convert.toFloat("1").floatValue(), 0.005);
assertEquals(1.0f, Convert.toFloatValue("1"), 0.005);
assertEquals(12, Convert.toInteger("12").intValue());
assertNotNull(Convert.toJDateTime(new GregorianCalendar()));
assertEquals(555, Convert.toLong("555").longValue());
assertEquals(555, Convert.toShort("555").shortValue());
assertEquals(55, Convert.toByte("55").byteValue());
assertNotNull(Convert.toString("555"));
}
use of jodd.datetime.JDateTime in project jodd by oblac.
the class DateConverterTest method testJDateTime2Date.
@Test
public void testJDateTime2Date() {
JDateTime jdt = new JDateTime(time);
Date date = dateConverter.convert(jdt);
assertEquals(time, date.getTime());
}
use of jodd.datetime.JDateTime in project jodd by oblac.
the class JDateTimeConverterTest method testDate2JDateTime.
@Test
public void testDate2JDateTime() {
Date date = new Date(time);
JDateTime jdt = jDateTimeConverter.convert(date);
assertEquals(time, jdt.getTimeInMillis());
}
Aggregations