Search in sources :

Example 11 with DateTime

use of org.mule.runtime.core.internal.el.datetime.DateTime in project mule by mulesoft.

the class DateTimeTestCase method isAfter.

@Test
public void isAfter() {
    Calendar cal = Calendar.getInstance();
    cal.add(DATE, -1);
    assertTrue(now.isAfter(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 12 with DateTime

use of org.mule.runtime.core.internal.el.datetime.DateTime in project mule by mulesoft.

the class DateTimeExpressionLanguageFunctionTestCase method parseISO8601String.

@Test
public void parseISO8601String() throws Exception {
    DateTime dateTime = (DateTime) dateTimeFunction.call(new Object[] { "2013-03-17T00:23:00Z" }, context);
    assertNotNull(dateTime);
    assertEquals(2013, dateTime.getYear());
    assertEquals(3, dateTime.getMonth());
    assertEquals(17, dateTime.getDayOfMonth());
    assertEquals(0, dateTime.getHours());
    assertEquals(23, dateTime.getMinutes());
    assertEquals(0, dateTime.getSeconds());
    assertEquals(0, dateTime.toCalendar().get(Calendar.ZONE_OFFSET));
}
Also used : DateTime(org.mule.runtime.core.internal.el.datetime.DateTime) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 13 with DateTime

use of org.mule.runtime.core.internal.el.datetime.DateTime in project mule by mulesoft.

the class DateTimeExpressionLanguageFunctionTestCase method parseISO8601StringWithTimeZome.

@Test
public void parseISO8601StringWithTimeZome() throws Exception {
    DateTime dateTime = (DateTime) dateTimeFunction.call(new Object[] { "2013-03-17T00:23:00+07:00" }, context);
    assertNotNull(dateTime);
    assertEquals(2013, dateTime.getYear());
    assertEquals(3, dateTime.getMonth());
    assertEquals(17, dateTime.getDayOfMonth());
    assertEquals(0, dateTime.getHours());
    assertEquals(23, dateTime.getMinutes());
    assertEquals(0, dateTime.getSeconds());
    assertEquals(7 * 1000 * 60 * 60, dateTime.toCalendar().get(Calendar.ZONE_OFFSET));
}
Also used : DateTime(org.mule.runtime.core.internal.el.datetime.DateTime) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 14 with DateTime

use of org.mule.runtime.core.internal.el.datetime.DateTime in project mule by mulesoft.

the class ServerContextTestCase method dateTime.

@Test
public void dateTime() {
    DateTime serverTime = (DateTime) evaluate("server.dateTime");
    long diff = new Date().getTime() - serverTime.toDate().getTime();
    assertThat("server.dateTime is not returning the current time", diff, lessThan(DEFAULT_TEST_TIMEOUT_SECS * 1000L));
    assertThat(evaluate("server.dateTime"), instanceOf(DateTime.class));
}
Also used : DateTime(org.mule.runtime.core.internal.el.datetime.DateTime) Date(java.util.Date) Test(org.junit.Test)

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