Package org.mule.el.datetime

Examples of org.mule.el.datetime.DateTime$InternalDate


        if (numParams == 1)
        {
            Object dateParam = params[0];
            if (dateParam instanceof Date)
            {
                return new DateTime((Date) dateParam);
            }
            else if (dateParam instanceof Calendar)
            {
                return new DateTime((Calendar) dateParam);
            }
            else if (dateParam instanceof XMLGregorianCalendar)
            {
                return new DateTime((XMLGregorianCalendar) dateParam);
            }
            else
            {
                try
                {
                    return new DateTime(dateParam.toString());
                }
                catch (RuntimeException e)
                {
                    throw new ExpressionRuntimeException(
                        CoreMessages.createStaticMessage("Unable to parse string as a ISO-8601 date"), e);
                }
            }
        }
        else
        {
            try
            {
                return new DateTime((String) params[0], (String) params[1]);
            }
            catch (ParseException e)
            {
                throw new ExpressionRuntimeException(
                    CoreMessages.createStaticMessage("Unable to parse string as a date using format '"
View Full Code Here


        return System.getProperty("user.dir");
    }

    public DateTime getDateTime()
    {
        return new DateTime();
    }
View Full Code Here

    }

    @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));
    }
View Full Code Here

    @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());
    }
View Full Code Here

    @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());
    }
View Full Code Here

    @Test
    public void dateTimeIsBefore()
    {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, 1);
        MuleMessage message = new DefaultMuleMessage(new DateTime(cal), muleContext);
        Assert.assertTrue((Boolean) evaluate("server.dateTime.isBefore(payload)", message));

    }
View Full Code Here

    }

    @Test
    public void dateTimeIsAfter()
    {
        MuleMessage message = new DefaultMuleMessage(new DateTime(Calendar.getInstance()), muleContext);
        Assert.assertTrue((Boolean) evaluate("server.dateTime.isAfter(payload)", message));
    }
View Full Code Here

    }

    @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));
    }
View Full Code Here

    }

    @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));
    }
View Full Code Here

    }

    @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));
    }
View Full Code Here

TOP

Related Classes of org.mule.el.datetime.DateTime$InternalDate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.