List of usage examples for java.text SimpleDateFormat setLenient
public void setLenient(boolean lenient)
From source file:de.berlios.jhelpdesk.web.ticket.TicketsViewController.java
@InitBinder public void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dateFormat.setLenient(true); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); binder.registerCustomEditor(User.class, userEditor); binder.registerCustomEditor(TicketCategory.class, ticketCategoryEditor); binder.registerCustomEditor(TicketPriorityEditor.class, ticketPriorityEditor); }
From source file:es.pode.modificador.presentacion.planificar.PlanificarControllerImpl.java
public final void planificar(ActionMapping mapping, es.pode.modificador.presentacion.planificar.PlanificarForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String actionSubmit = form.getAction(); int day, year, month, hour, minute; Calendar fechaHoy = Calendar.getInstance(); if (actionSubmit.equals("Aceptar")) { if (form.getFecha() == null || form.getFecha().equals("")) { throw new ValidatorException("{planificar.msgErrorFecha}"); } else if (form.getHoras() == null || form.getHoras().equals("")) { throw new ValidatorException("{planificar.msgErrorHora}"); } else if (form.getMinutos() == null || form.getMinutos().equals("")) { throw new ValidatorException("{planificar.msgErrorMinutos}"); } else {//from w w w .j av a2 s . co m String idModificacion = form.getIdModificacion(); try { hour = Integer.valueOf(form.getHoras()).intValue(); minute = Integer.valueOf(form.getMinutos()).intValue(); } catch (Exception e) { throw new ValidatorException("{planificar.msgErrorFormato}"); } try { StringBuffer fechaStr = new StringBuffer(); fechaStr.append(form.getFecha()).append(guion).append(hour).append(guion); fechaStr.append(minute); SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy-HH-mm"); format.setLenient(false); Date fecha = format.parse(fechaStr.toString()); Calendar fechaEjecucion = Calendar.getInstance(); fechaEjecucion.setTime(fecha); if (fechaHoy.before(fechaEjecucion)) { Long idModificacionLong = Long.valueOf(idModificacion); this.getSrvHerramientaModificacion().planificarModificacion(idModificacionLong, fechaEjecucion); } else { throw new ValidatorException("{planificar.msgErrorFecha}"); } } catch (ParseException e1) { throw new ValidatorException("{planificar.msgErrorFormato}"); } catch (ValidatorException e2) { throw new ValidatorException("{planificar.msgErrorFecha}"); } catch (Exception e3) { throw new ValidatorException("{planificar.msgExcepcion}"); } } } }
From source file:net.heroicefforts.viable.android.dao.Comment.java
/** * Instantiate the comment state based upon the JIRA JSON format. * /* ww w .j ava 2 s .c o m*/ * @param obj JIRA JSON comment object * @throws JSONException if there's an error parsing the JSON. */ public Comment(JSONObject jsonObject) throws JSONException { this.id = jsonObject.getLong("id"); this.body = jsonObject.getString("body").replaceAll("\r\n", "\n"); if (jsonObject.has("author")) this.author = jsonObject.getString("author"); SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); fmt.setLenient(true); try { createDate = fmt.parse(jsonObject.getString("createDate")); } catch (ParseException e) { Log.e(TAG, "Error parsing JSON dates.", e); throw new JSONException("Error parsing JSON dates."); } }
From source file:com.microsoft.tfs.util.datetime.LenientDateTimeParserExpander.java
/** * Add a single format to this expander's contents. * * @param pattern/*from ww w . j ava 2 s.c om*/ * the single pattern string to add (not null). */ public void addExpanded(final String pattern, final boolean specifiesDate, final boolean specifiesTime) { final SimpleDateFormat sdf = new SimpleDateFormat(pattern, locale); sdf.setLenient(constructLenient); lenientDateTimeParserFormats.add(new LenientDateTimeFormat(sdf, counter++, specifiesDate, specifiesTime)); }
From source file:net.sf.jasperreports.engine.util.JRDateLocaleConverter.java
/** * *//*ww w . ja v a2 s . c o m*/ private SimpleDateFormat getFormatter(String pattern, Locale locale) { if (pattern == null) { pattern = locPattern ? new SimpleDateFormat().toLocalizedPattern() : new SimpleDateFormat().toPattern(); log.warn("Null pattern was provided, defaulting to: " + pattern); } SimpleDateFormat format = new SimpleDateFormat(pattern, locale); if (timeZone != null) { format.setTimeZone(timeZone); } format.setLenient(isLenient()); return format; }
From source file:org.jasig.ssp.web.api.reports.AddressLabelsReportController.java
@InitBinder public void initBinder(final WebDataBinder binder) { final SimpleDateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT, Locale.US); dateFormat.setLenient(false); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); }
From source file:com.jp.systemdirector.projectzero.zab01.pr.SZAB0111Action.java
protected Date dateFormate(String date) { SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyyMMddhhmiss"); sDateFormat.setLenient(false); if (DateValidator.getInstance().isValid(date, "yyyyMMddhhmiss", true) == false) { return null; } else {// ww w . jav a2 s . c o m try { return sDateFormat.parse(date); } catch (ParseException ex) { log.error(ex); return null; } } }
From source file:com.amediamanager.controller.VideoController.java
@InitBinder public void initDateBinder(final WebDataBinder dataBinder) { // Bind dates final String dateformat = "MM/dd/yyyy"; final SimpleDateFormat sdf = new SimpleDateFormat(dateformat); sdf.setLenient(false); dataBinder.registerCustomEditor(Date.class, new CustomDateEditor(sdf, false)); }
From source file:org.jrecruiter.web.controller.BaseFormController.java
/** * Set up a custom property editor for converting form inputs to real objects * @param request the current request/*from w ww . j av a2 s .c o m*/ * @param binder the data binder */ @InitBinder protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) { binder.registerCustomEditor(Integer.class, null, new CustomNumberEditor(Integer.class, null, true)); binder.registerCustomEditor(Long.class, null, new CustomNumberEditor(Long.class, null, true)); binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor()); SimpleDateFormat dateFormat = new SimpleDateFormat(getText("date.format", request.getLocale())); dateFormat.setLenient(false); binder.registerCustomEditor(Date.class, null, new CustomDateEditor(dateFormat, true)); }