@Test public void testTimeFormat() throws Exception { Date date = new SimpleDateFormat("HH:mm:ss").parse("18:09:35"); TimeWidget widget = new TimeWidget(); widget.setInitialValue(date); setGlobalProperty(""); testTimeFormat(widget, "18:09"); setGlobalProperty("h:mm a"); testTimeFormat(widget, "6:09 PM"); widget.setTimeFormat("mm.ss"); testTimeFormat(widget, "09.35"); }
private SimpleDateFormat timeFormat() { String df = timeFormat != null ? timeFormat : Context.getAdministrationService().getGlobalProperty(HtmlFormEntryConstants.GP_TIME_FORMAT); if (!StringUtils.hasText(df)) { df = DEFAULT_TIME_FORMAT; } return new SimpleDateFormat(df, Context.getLocale()); }
TimeWidget implements Widget { private SimpleDateFormat timeFormat() { String df = timeFormat != null ? timeFormat : Context.getAdministrationService().getGlobalProperty(HtmlFormEntryConstants.GP_TIME_FORMAT); if (!StringUtils.hasText(df)) { df = DEFAULT_TIME_FORMAT; } return new SimpleDateFormat(df, Context.getLocale()); } }
TimeWidget implements Widget { private SimpleDateFormat timeFormat() { String df = timeFormat != null ? timeFormat : Context.getAdministrationService().getGlobalProperty(HtmlFormEntryConstants.GP_TIME_FORMAT); if (!StringUtils.hasText(df)) { df = DEFAULT_TIME_FORMAT; } return new SimpleDateFormat(df, Context.getLocale()); } TimeWidget(); }
TimeWidget implements Widget { private SimpleDateFormat timeFormat() { String df = timeFormat != null ? timeFormat : Context.getAdministrationService().getGlobalProperty(HtmlFormEntryConstants.GP_TIME_FORMAT); if (!StringUtils.hasText(df)) { df = DEFAULT_TIME_FORMAT; } return new SimpleDateFormat(df, Context.getLocale()); } TimeWidget(); @Override String generateHtml(FormEntryContext context); @Override Object getValue(FormEntryContext context, HttpServletRequest request); @Override void setInitialValue(Object value); void setHidden(boolean hidden); void setHideSeconds(boolean hideSeconds); boolean isHidden(); void setTimeFormat(String timeFormat); }
TimeWidget implements Widget { private SimpleDateFormat timeFormat() { String df = timeFormat != null ? timeFormat : Context.getAdministrationService().getGlobalProperty(HtmlFormEntryConstants.GP_TIME_FORMAT); if (!StringUtils.hasText(df)) { df = DEFAULT_TIME_FORMAT; } return new SimpleDateFormat(df, Context.getLocale()); } TimeWidget(); @Override String generateHtml(FormEntryContext context); @Override Object getValue(FormEntryContext context, HttpServletRequest request); @Override void setInitialValue(Object value); void setHidden(boolean hidden); void setHideSeconds(boolean hideSeconds); boolean isHidden(); void setTimeFormat(String timeFormat); static final String DEFAULT_TIME_FORMAT; }