Example usage for org.springframework.beans.propertyeditors CustomDateEditor CustomDateEditor

List of usage examples for org.springframework.beans.propertyeditors CustomDateEditor CustomDateEditor

Introduction

In this page you can find the example usage for org.springframework.beans.propertyeditors CustomDateEditor CustomDateEditor.

Prototype

public CustomDateEditor(DateFormat dateFormat, boolean allowEmpty) 

Source Link

Document

Create a new CustomDateEditor instance, using the given DateFormat for parsing and rendering.

Usage

From source file:org.openmrs.scheduler.web.controller.SchedulerFormController.java

/**
 * Allows for Integers to be used as values in input tags. Normally, only strings and lists are
 * expected//from  w w w. j a  v  a  2s .  c  o m
 * 
 * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest,
 *      org.springframework.web.bind.ServletRequestDataBinder)
 */
@Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
    super.initBinder(request, binder);
    binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true));
    binder.registerCustomEditor(java.lang.Long.class, new CustomNumberEditor(java.lang.Long.class, true));
    binder.registerCustomEditor(java.util.Date.class,
            new CustomDateEditor(new SimpleDateFormat(DEFAULT_DATE_PATTERN), true));
}

From source file:csns.web.controller.MFTIndicatorController.java

@InitBinder
public void initBinder(WebDataBinder binder, WebRequest request) {
    binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("MM/dd/yyyy"), true));
}

From source file:org.opentides.web.controller.WidgetController.java

@InitBinder
protected void registerEditor(WebDataBinder binder) throws Exception {
    binder.registerCustomEditor(Date.class, "lastCacheUpdate",
            new CustomDateEditor(new SimpleDateFormat("MMM dd, yyyy hh:mm:ss"), true));
}

From source file:sample.portlet.BookEditController.java

@Override
protected void initBinder(PortletRequest request, PortletRequestDataBinder binder) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.US);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
    binder.setAllowedFields(/*ww  w . j a  v a  2  s .  c o m*/
            new String[] { "author", "title", "description", "availability", "count", "website", "coverPng" });
}

From source file:io.github.benas.todolist.web.controller.TodoController.java

@InitBinder
public void initBinder(WebDataBinder binder) {
    SimpleDateFormat dateFormat = new SimpleDateFormat(TodoListUtils.DATE_FORMAT);
    dateFormat.setLenient(false);//from w  w w  .  j a  v  a 2 s. c  o m
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
    binder.registerCustomEditor(Priority.class, new TodoPriorityPropertyEditor());
}

From source file:org.openmrs.module.sync.web.controller.StatisticsController.java

/**
 * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest,
 *      org.springframework.web.bind.ServletRequestDataBinder)
 *//*from w  w w  . j a v  a 2 s  .  com*/
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
    super.initBinder(request, binder);
    binder.registerCustomEditor(java.util.Date.class,
            new CustomDateEditor(new SimpleDateFormat(Context.getAdministrationService().getGlobalProperty(
                    SyncConstants.PROPERTY_DATE_PATTERN, SyncConstants.DEFAULT_DATE_PATTERN)), true));
}

From source file:com.github.dbourdette.glass.job.GlassJobFactory.java

private AbstractPropertyAccessor buildAccessor(Job job) {
    AbstractPropertyAccessor accessor = null;

    if (configuration.getInjectionType() == InjectionType.FIELD) {
        accessor = new DirectFieldAccessor(job);
    } else {//from   w  w  w .java 2 s . c om
        accessor = new BeanWrapperImpl(job);
    }

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(configuration.getDateFormat());
    CustomDateEditor customDateEditor = new CustomDateEditor(simpleDateFormat, true);
    accessor.registerCustomEditor(Date.class, customDateEditor);

    return accessor;
}

From source file:com.alibaba.intl.bcds.goldroom.web.FillBookInfoController.java

protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {

    DateFormat fmt = new SimpleDateFormat("yyyy-M-d");
    CustomDateEditor dateEditor = new CustomDateEditor(fmt, true);
    binder.registerCustomEditor(Date.class, dateEditor);
    super.initBinder(request, binder);
}

From source file:de.berlios.jhelpdesk.web.preferences.filter.CustomFilterEditController.java

@InitBinder
public void initBinder(WebDataBinder binder) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setLenient(true);//from w  w w .  jav  a2 s .  co m
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    binder.registerCustomEditor(User.class, userEditor);
    binder.registerCustomEditor(TicketCategory.class, categoryEditor);
}

From source file:edu.duke.cabig.c3pr.web.report.CreateReportController.java

@Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
    super.initBinder(request, binder);

    binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("MM/dd/yyyy"), true));

    if (request.getMethod().equals(METHOD_GET)) {
        CreateReportFacade studyFacade = new CreateReportFacade();
        Context context = null;//from   ww w. j  a v a  2s. co m
        context = new HttpServletRequestContext(request);

        TableModel model = new TableModelImpl(context);
        Object viewData = null;
        try {
            viewData = studyFacade.build(model, null);
        } catch (Exception e) {
            e.printStackTrace();
        }
        request.setAttribute("assembler", viewData);
    }
}