/** * Returns a {@link Comparison} between the result of * {@link #getCalendar()} and the specified date. The default * rendering of that Comparison will be the largest unit difference * between the dates followed by a description of their relative position. * * @param then The date in question * @return {@link Comparison} object */ public Comparison whenIs(Object then) { return compare(getCalendar(), then, CURRENT_TYPE); }
/** * Internal comparison method. * @param now The date to use as representative of "now" * @param then The secondary date * @param type Difference type * @return {@link Comparison} object */ protected Comparison compare(Object now, Object then, int type) { Calendar calThen = toCalendar(then); Calendar calNow = toCalendar(now); if (calThen == null || calNow == null) { return null; } long ms = calThen.getTimeInMillis() - calNow.getTimeInMillis(); return new Comparison(ms, type, this.depth, false, null); }
/** * Initializes Velocity engine */ private void init() { velocityEngine.setProperty(VelocityEngine.RESOURCE_LOADER, "class"); velocityEngine.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); setLogFile(); DateTool dateTool = new DateTool(); dateTool.configure(this.configMap); MathTool mathTool = new MathTool(); NumberTool numberTool = new NumberTool(); numberTool.configure(this.configMap); SortTool sortTool = new SortTool(); defaultContext = new VelocityContext(); defaultContext.put("dateTool", dateTool); defaultContext.put("dateComparisonTool", new ComparisonDateTool()); defaultContext.put("mathTool", mathTool); defaultContext.put("numberTool", numberTool); defaultContext.put("sortTool", sortTool); // Following tools need VelocityTools version 2.0+ //defaultContext.put("displayTool", new DisplayTool()); //defaultContext.put("xmlTool", new XmlTool()); try { velocityEngine.init(); } catch (Exception e) { throw new VelocityException(e); } }
/** * Returns a {@link Comparison} between the result of * the second specified date and the first specified date. The default * rendering of that Comparison will be the largest unit difference * between the dates. * * @param now The date to use as representative of "now" * @param then The secondary date * @return {@link Comparison} object */ public Comparison difference(Object now, Object then) { return compare(now, then, DIFF_TYPE); }
Locale defaultLocale = getLocale(); ResourceBundle bundle = null;
/** * Initializes Velocity engine */ private void init() { velocityEngine.setProperty(VelocityEngine.RESOURCE_LOADER, "class"); velocityEngine.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); setLogFile(); DateTool dateTool = new DateTool(); dateTool.configure(this.configMap); MathTool mathTool = new MathTool(); NumberTool numberTool = new NumberTool(); numberTool.configure(this.configMap); SortTool sortTool = new SortTool(); defaultContext = new VelocityContext(); defaultContext.put("dateTool", dateTool); defaultContext.put("dateComparisonTool", new ComparisonDateTool()); defaultContext.put("mathTool", mathTool); defaultContext.put("numberTool", numberTool); defaultContext.put("sortTool", sortTool); // Following tools need VelocityTools version 2.0+ //defaultContext.put("displayTool", new DisplayTool()); //defaultContext.put("xmlTool", new XmlTool()); try { velocityEngine.init(); } catch (Exception e) { throw new VelocityException(e); } }
/** * Returns a {@link Comparison} between the second specified date * and the first specified date. The default * rendering of that Comparison will be the largest unit difference * between the dates followed by a description of their relative position. * * @param now The date to use as representative of "now" * @param then The date in question * @return {@link Comparison} object */ public Comparison whenIs(Object now, Object then) { return compare(now, then, RELATIVE_TYPE); }
/** * Initializes Velocity engine */ private void init() { velocityEngine.setProperty(VelocityEngine.RESOURCE_LOADER, "class"); velocityEngine.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); setLogFile(); DateTool dateTool = new DateTool(); dateTool.configure(this.configMap); MathTool mathTool = new MathTool(); NumberTool numberTool = new NumberTool(); numberTool.configure(this.configMap); SortTool sortTool = new SortTool(); defaultContext = new VelocityContext(); defaultContext.put("dateTool", dateTool); defaultContext.put("dateComparisonTool", new ComparisonDateTool()); defaultContext.put("mathTool", mathTool); defaultContext.put("numberTool", numberTool); defaultContext.put("sortTool", sortTool); // Following tools need VelocityTools version 2.0+ //defaultContext.put("displayTool", new DisplayTool()); //defaultContext.put("xmlTool", new XmlTool()); try { velocityEngine.init(); } catch (Exception e) { throw new VelocityException(e); } }
context.put("number", new NumberTool()); context.put("list", new ListTool()); context.put("date", new ComparisonDateTool()); context.put("math", new MathTool()); context.put("engine", engine); // for $engine.resourceExists(...)
context.put("date", new ComparisonDateTool()); context.put("list", new ListTool()); context.put(SORT, new SortTool());