Search in sources :

Example 1 with DateTime

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();
    }
}
Also used : DateTime(org.mule.runtime.core.internal.el.datetime.DateTime) Test(org.junit.Test)

Example 2 with DateTime

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());
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DateTime(org.mule.runtime.core.internal.el.datetime.DateTime) Test(org.junit.Test)

Example 3 with DateTime

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());
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DateTime(org.mule.runtime.core.internal.el.datetime.DateTime) Test(org.junit.Test)

Example 4 with DateTime

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)));
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DateTime(org.mule.runtime.core.internal.el.datetime.DateTime) Test(org.junit.Test)

Example 5 with DateTime

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());
}
Also used : Date(java.util.Date) DateTime(org.mule.runtime.core.internal.el.datetime.DateTime) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Aggregations

Test (org.junit.Test)14 DateTime (org.mule.runtime.core.internal.el.datetime.DateTime)14 SmallTest (org.mule.tck.size.SmallTest)6 Calendar (java.util.Calendar)5 GregorianCalendar (java.util.GregorianCalendar)4 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)4 Date (java.util.Date)3 Locale (java.util.Locale)1 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)1 InternalMessage (org.mule.runtime.core.internal.message.InternalMessage)1