Package org.apache.velocity.tools.generic

Examples of org.apache.velocity.tools.generic.DateTool


    protected void assertStringEquals(String expected, Object testThis) {
        assertEquals(expected, String.valueOf(testThis));
    }

    public @Test void testDateTool() { /* TODO still incomplete */
        DateTool dateTool = (DateTool)toolbox.get("date");
        assertNotNull(dateTool);
        Date date = new GregorianCalendar(2007,0,2).getTime();
        String disp = "2007-01-02";
        String disp2 = "2007/01/02";
        /* check configured format */
        assertEquals("yyyy-MM-dd",dateTool.getFormat());
        /* test formatting */
        assertEquals(disp,dateTool.format(date));
        assertEquals(disp2,dateTool.format("yyyy/MM/dd",date));
        /* test parsing */
        assertEquals(2007,dateTool.getYear(disp));
        assertEquals(0,dateTool.getMonth(disp));
        assertEquals(2,dateTool.getDay(disp));
    }
View Full Code Here


        assertEquals("myValue", context.get("myHelper"));
        assertTrue(context.get("math") instanceof MathTool);

        assertTrue(context.get("dateTool") instanceof DateTool);
        DateTool dateTool = (DateTool) context.get("dateTool");
        assertTrue(dateTool.getLocale().equals(Locale.CANADA));

        assertTrue(context.get("numberTool") instanceof NumberTool);
        NumberTool numberTool = (NumberTool) context.get("numberTool");
        assertTrue(numberTool.getLocale().equals(Locale.CANADA));
      }
View Full Code Here

    Velocity.setProperty("file.resource.loader.path", xml.getParent());
    Velocity.setProperty("file.resource.loader.cache", false);
    Velocity.init();
    tmp = Velocity.getTemplate(xml.getName(),"UTF-8");
    context.put("convert", new ConversionTool());
    context.put("dateTool", new DateTool());
    context.put("mathTool", new MathTool());
    context.put("numberTool", new NumberTool());
    context.put("Math", new myMath());
  }
View Full Code Here

TOP

Related Classes of org.apache.velocity.tools.generic.DateTool

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.