use of org.mule.runtime.core.internal.el.datetime.DateTime in project mule by mulesoft.
the class DateTimeTestCase method serialization.
@Test
public void serialization() throws Exception {
final String key = "key";
ObjectStore<DateTime> os = muleContext.getObjectStoreManager().createObjectStore("DateTimeTestCase", unmanagedPersistent());
try {
os.store(key, now);
DateTime recovered = os.retrieve(key);
assertEquals(now, recovered);
} finally {
os.clear();
}
}
use of org.mule.runtime.core.internal.el.datetime.DateTime in project mule by mulesoft.
the class DateTimeTestCase method fromXMLCalendar.
@Test
public void fromXMLCalendar() throws DatatypeConfigurationException {
XMLGregorianCalendar xmlCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar());
xmlCal.setYear(1900);
xmlCal.setMonth(1);
xmlCal.setDay(1);
assertEquals(1900, new DateTime(xmlCal).getYear());
assertEquals(1, new DateTime(xmlCal).getMonth());
assertEquals(1, new DateTime(xmlCal).getDayOfMonth());
}
use of org.mule.runtime.core.internal.el.datetime.DateTime in project mule by mulesoft.
the class DateTimeTestCase method fromCalendar.
@Test
public void fromCalendar() {
Calendar cal = new GregorianCalendar();
cal.set(Calendar.YEAR, 1900);
cal.set(MONTH, 0);
cal.set(DAY_OF_MONTH, 1);
assertEquals(1900, new DateTime(cal).getYear());
assertEquals(1, new DateTime(cal).getMonth());
assertEquals(1, new DateTime(cal).getDayOfMonth());
}
use of org.mule.runtime.core.internal.el.datetime.DateTime in project mule by mulesoft.
the class DateTimeTestCase method isBefore.
@Test
public void isBefore() {
Calendar cal = Calendar.getInstance();
cal.add(DATE, 1);
assertTrue(now.isBefore(new DateTime(cal)));
}
use of org.mule.runtime.core.internal.el.datetime.DateTime in project mule by mulesoft.
the class DateTimeExpressionLanguageFunctionTestCase method convertDate.
@Test
public void convertDate() throws Exception {
Date date = new Date();
DateTime dateTime = (DateTime) dateTimeFunction.call(new Object[] { date }, context);
assertNotNull(dateTime);
assertEquals(date.getYear() + 1900, dateTime.getYear());
assertEquals(date.getMonth() + 1, dateTime.getMonth());
assertEquals(date.getDate(), dateTime.getDayOfMonth());
assertEquals(date.getHours(), dateTime.getHours());
assertEquals(date.getMinutes(), dateTime.getMinutes());
assertEquals(date.getSeconds(), dateTime.getSeconds());
}
Aggregations