Example usage for java.text SimpleDateFormat setLenient

List of usage examples for java.text SimpleDateFormat setLenient

Introduction

In this page you can find the example usage for java.text SimpleDateFormat setLenient.

Prototype

public void setLenient(boolean lenient) 

Source Link

Document

Specify whether or not date/time parsing is to be lenient.

Usage

From source file:org.orderofthebee.addons.support.tools.share.ContentStreamer.java

protected static SimpleDateFormat getHTTPDateFormat() {
    if (s_dateFormat.get() != null) {
        return s_dateFormat.get();
    }//  w  w  w .  jav  a  2s  . c om

    final SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy kk:mm:ss zzz");
    formatter.setLenient(false);
    formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
    s_dateFormat.set(formatter);
    return s_dateFormat.get();
}

From source file:org.parancoe.basicWebApp.controllers.BasicWebAppBindingInitializer.java

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

From source file:org.wso2.carbon.mdm.services.android.services.impl.DeviceManagementAdminServiceImpl.java

private static void validateScheduleDate(String dateString) {
    try {// ww  w  .  jav  a 2  s  . c om
        if (dateString != null && !dateString.isEmpty()) {
            SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
            sdf.setLenient(false);
            sdf.parse(dateString);
        }
    } catch (ParseException e) {
        String errorMessage = "Issue in validating the schedule date";
        log.error(errorMessage);
        throw new BadRequestException(
                new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
    }
}

From source file:com.github.bysrhq.belajar.domain.formatter.DateFormatter.java

private SimpleDateFormat createDateFormat(final Locale locale) {
    String format = messageSource.getMessage("date.format", null, locale);
    SimpleDateFormat dateFormat = new SimpleDateFormat(format);
    dateFormat.setLenient(false);

    return dateFormat;
}

From source file:com.benfante.minimark.controllers.AppBindingInitializer.java

public void initBinder(WebDataBinder binder, WebRequest request) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    if (binder.getTarget() != null) {
        binder.setMessageCodesResolver(new ModelAwareMessageCodesResolver());
    }/*  w  w  w.  ja va2  s  .c o m*/
}

From source file:com.kzk.stsm.conversion.DateFormatter.java

private SimpleDateFormat createDateFormat(final Locale locale) {
    final String format = this.messageSource.getMessage("seedstarter.date.format", null, locale);
    final SimpleDateFormat dateFormat = new SimpleDateFormat(format);
    dateFormat.setLenient(false);
    return dateFormat;
}

From source file:com.zeroone.guestebook.DateFormatter.java

private SimpleDateFormat createDateFormat(Locale locale) {
    String format;// w ww.j  av a  2  s .co m
    format = messageSource.getMessage("guestbook.date.format", null, locale);
    SimpleDateFormat dateFormat = new SimpleDateFormat(format);
    dateFormat.setLenient(false);
    return dateFormat;
}

From source file:testapp.view.conversion.DateFormatter.java

private SimpleDateFormat createDateFormat(final Locale locale) {
    final String format = this.messageSource.getMessage("date.format", null, locale);
    final SimpleDateFormat dateFormat = new SimpleDateFormat(format);
    dateFormat.setLenient(false);
    return dateFormat;
}

From source file:org.xlcloud.openstack.model.climate.json.OpenStackDateDeserializer.java

private Date parseDate(String input, String[] datePatterns) throws ParseException {
    SimpleDateFormat parser = new SimpleDateFormat();
    parser.setLenient(true);
    parser.setTimeZone(DateUtils.UTC_TIME_ZONE);
    ParsePosition position = new ParsePosition(0);
    for (String datePattern : datePatterns) {
        parser.applyPattern(datePattern);
        Date date = parser.parse(input, position);
        if (date != null && position.getIndex() == input.length()) {
            return date;
        }/* w  w w . j a  v a  2  s . c o  m*/
    }
    throw new ParseException("Unable to parse the date: " + input, -1);
}

From source file:egovframework.rte.cmmn.web.EgovBindingInitializer.java

/**
* initBinder/*  www  . jav a2 s  .c  om*/
* @param binder
* @param request
* @see ??  
*/
public void initBinder(WebDataBinder binder, WebRequest request) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(false));
}