예제 #1
0
 private NowWidget widget(String widgetPattern, final String datePattern) {
   NowWidget widget = new NowWidget(null, widgetPattern);
   widget.setCalenderFactory(
       new NowWidget.CalendarFactory() {
         @Override
         public Calendar build() {
           Calendar calendar = Calendar.getInstance();
           try {
             calendar.setTime(FORMATTER.parse(datePattern));
           } catch (ParseException e) {
             throw new RuntimeException(e);
           }
           return calendar;
         }
       });
   return widget;
 }
예제 #2
0
 public void test_callRenderMultipleTimesWithDateManipulation() throws Exception {
   NowWidget widget = widget("!now pattern(yyyy) month(6)", "01/01/2000");
   assertEquals("2000", widget.render());
   assertEquals("2000", widget.render());
 }