@Override public SimpleDateFormat getSimpleDateFormatter() { return FormatUtil.getDateFormat(); }
public void setLastModDate(Date lastModDate) { if (lastModDate != null) { lastmod = FormatUtil.formatDateUsingW3C(lastModDate); } else { lastmod = FormatUtil.formatDateUsingW3C(new Date()); } }
/** * Converts a field to the specified type. Useful when * @param type * @param fieldValue * @return */ public static Object convertField(String type, String fieldValue) { if (fieldValue == null) { return null; } try { if (type.equals(SupportedFieldType.BOOLEAN.toString())) { return Boolean.parseBoolean(fieldValue); } else if (type.equals(SupportedFieldType.DATE.toString())) { return FormatUtil.getTimeZoneFormat().parse(fieldValue); } else if (type.equals(SupportedFieldType.INTEGER.toString())) { return Integer.parseInt(fieldValue); } else if (type.equals(SupportedFieldType.MONEY.toString()) || type.equals(SupportedFieldType.DECIMAL.toString())) { return new BigDecimal(fieldValue); } } catch (ParseException e) { throw new RuntimeException(e); } throw new IllegalArgumentException("Unrecognized type(" + type + ") for map field conversion."); }
/** * Parse the string value of the date stored in mvel * * @param date the mvel date value * @return the parsed Date instance */ public static Date parseDate(String date) throws ParseException { Date parsedDate; try { parsedDate = FormatUtil.getTimeZoneFormat().parse(date); } catch (ParseException e) { try { SimpleDateFormat formatter = new SimpleDateFormat(COMPATIBILITY_FORMAT); formatter.setTimeZone(BroadleafRequestContext.getBroadleafRequestContext().getTimeZone()); parsedDate = formatter.parse(date); } catch (ParseException e1) { try { SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT); formatter.setTimeZone(BroadleafRequestContext.getBroadleafRequestContext().getTimeZone()); parsedDate = formatter.parse(date); } catch (ParseException e2) { throw e; } } } return parsedDate; } }
@Override public Date convert(String stringValue) { return parseDate(stringValue, FormatUtil.getDateFormat()); }
"and you entered: (" + parsableVal +"). Dates must be in the format MM/dd/yyyy HH:mm."); String convertedDate = FormatUtil.getTimeZoneFormat().format(temp); response.append("MvelHelper.convertField(\"DATE\",\""); response.append(convertedDate);
if (startTime != null) { Date start = new Date(getStartTime()); sb.append(", startTime=").append(FormatUtil.formatDateUsingW3C(start)).append("\n"); Long endTime = System.currentTimeMillis(); Date end = new Date(endTime); sb.append(", endTime=").append(FormatUtil.formatDateUsingW3C(end)).append("\n"); Long duration = endTime - startTime; long hours = TimeUnit.MILLISECONDS.toHours(duration);
DateFormat format = FormatUtil.getDateFormat(); if (defaultValue.toLowerCase().contains("today")) { defaultValue = format.format(new Date());
String now = FormatUtil.formatDateUsingW3C(new Date());
case DATE: try { value = FormatUtil.getDateFormat().parse(originalValue); } catch (Exception e) { value = originalValue;
case DATE: try { value = FormatUtil.getDateFormat().parse(originalValue); } catch (Exception e) { value = originalValue;