use of org.mule.runtime.core.internal.el.datetime.DateTime in project mule by mulesoft.
the class DateTimeExpressionLanguageFunctionTestCase method parseFormattedStringWithTimeZone.
@Test
public void parseFormattedStringWithTimeZone() throws Exception {
DateTime dateTime = (DateTime) dateTimeFunction.call(new Object[] { "17/3/13 00:23:00 -0700", "dd/M/yy hh:mm:ss ZZ" }, 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));
}
use of org.mule.runtime.core.internal.el.datetime.DateTime in project mule by mulesoft.
the class DateTimeExpressionLanguageFunctionTestCase method convertCalendar.
@Test
public void convertCalendar() throws Exception {
Calendar cal = Calendar.getInstance();
DateTime dateTime = (DateTime) dateTimeFunction.call(new Object[] { cal }, context);
assertNotNull(dateTime);
assertEquals(cal.get(Calendar.YEAR), dateTime.getYear());
assertEquals(cal.get(Calendar.MONTH) + 1, dateTime.getMonth());
assertEquals(cal.get(Calendar.DAY_OF_MONTH), dateTime.getDayOfMonth());
assertEquals(cal.get(Calendar.HOUR_OF_DAY), dateTime.getHours());
assertEquals(cal.get(Calendar.MINUTE), dateTime.getMinutes());
assertEquals(cal.get(Calendar.SECOND), dateTime.getSeconds());
}
use of org.mule.runtime.core.internal.el.datetime.DateTime in project mule by mulesoft.
the class DateTimeExpressionLanguageFunctionTestCase method parseFormattedString.
@Test
public void parseFormattedString() throws Exception {
DateTime dateTime = (DateTime) dateTimeFunction.call(new Object[] { "17/3/13 00:23:00", "dd/M/yy hh:mm:ss" }, 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));
}
use of org.mule.runtime.core.internal.el.datetime.DateTime in project mule by mulesoft.
the class AbstractSerializerProtocolContractTestCase method serializeWithoutDefaultConstructor.
@Test
public final void serializeWithoutDefaultConstructor() throws Exception {
Calendar calendar = Calendar.getInstance();
Locale locale = Locale.ITALIAN;
DateTime dateTime = new DateTime(calendar, locale);
dateTime.changeTimeZone("Pacific/Midway");
CoreEvent event = eventBuilder(muleContext).message(of(dateTime)).build();
byte[] bytes = serializationProtocol.serialize(event.getMessage());
InternalMessage message = serializationProtocol.deserialize(bytes);
DateTime deserealized = (DateTime) message.getPayload().getValue();
assertEquals(calendar, deserealized.toCalendar());
assertEquals(dateTime.format(), deserealized.format());
}
use of org.mule.runtime.core.internal.el.datetime.DateTime in project mule by mulesoft.
the class DateTimeTestCase method fromDate.
@Test
public void fromDate() {
Date date = new Date();
date.setYear(0);
date.setMonth(0);
date.setDate(1);
assertEquals(1900, new DateTime(date).getYear());
assertEquals(1, new DateTime(date).getMonth());
assertEquals(1, new DateTime(date).getDayOfMonth());
}
Aggregations