public Object execute(Object iThis, final OIdentifiable iCurrentRecord, final Object iCurrentResult, final Object[] iParams, OCommandContext iContext) { if (iParams.length == 0) return date; if (iParams[0] == null) return null; if (iParams[0] instanceof Number) return new Date(((Number) iParams[0]).longValue()); if (format == null) { if (iParams.length > 1) { format = new SimpleDateFormat((String) iParams[1]); format.setTimeZone(ODateHelper.getDatabaseTimeZone()); } else format = ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().getDateTimeFormatInstance(); if (iParams.length == 3) format.setTimeZone(TimeZone.getTimeZone(iParams[2].toString())); } try { return format.parse((String) iParams[0]); } catch (ParseException e) { throw OException.wrapException(new OQueryParsingException("Error on formatting date '" + iParams[0] + "' using the format: " + format.toPattern()), e); } }
formatter = config.getDateTimeFormatInstance();
@Override public Object execute(Object iThis, OIdentifiable iCurrentRecord, OCommandContext iContext, Object ioResult, Object[] iParams) { if (iThis != null) { if (iThis instanceof Date) { return iThis; } else if (iThis instanceof Number) { return new Date(((Number) iThis).longValue()); } else { try { return ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().getDateTimeFormatInstance().parse(iThis.toString()); } catch (ParseException e) { OLogManager.instance().error(this, "Error during %s execution", e, NAME); // IGNORE IT: RETURN NULL } } } return null; } }
public static DateFormat getDateTimeFormatInstance() { final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null && !db.isClosed()) return db.getStorage().getConfiguration().getDateTimeFormatInstance(); else return new SimpleDateFormat(DEF_DATETIME_FORMAT); }
else try { result = ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().getDateTimeFormatInstance() .parse(currentValue.toString()); } catch (ParseException ignore) {
return new Date(Long.parseLong(iValue.toString())); try { return ODatabaseRecordThreadLocal.instance().get().getStorage().getConfiguration().getDateTimeFormatInstance() .parse((String) iValue); } catch (ParseException ignore) {
public static Object getPrettyFieldValue(Object value, final int multiValueMaxEntries) { if (value instanceof OMultiCollectionIterator<?>) value = getPrettyFieldMultiValue(((OMultiCollectionIterator<?>) value).iterator(), multiValueMaxEntries); else if (value instanceof ORidBag) value = getPrettyFieldMultiValue(((ORidBag) value).rawIterator(), multiValueMaxEntries); else if (value instanceof Iterator) value = getPrettyFieldMultiValue((Iterator<?>) value, multiValueMaxEntries); else if (value instanceof Collection<?>) value = getPrettyFieldMultiValue(((Collection<?>) value).iterator(), multiValueMaxEntries); else if (value instanceof ORecord) { if (((ORecord) value).getIdentity().equals(ORecordId.EMPTY_RECORD_ID)) { value = ((ORecord) value).toString(); } else { value = ((ORecord) value).getIdentity().toString(); } } else if (value instanceof Date) { final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) value = db.getStorage().getConfiguration().getDateTimeFormatInstance().format((Date) value); else { value = DEF_DATEFORMAT.format((Date) value); } } else if (value instanceof byte[]) value = "byte[" + ((byte[]) value).length + "]"; return value; }
formatter = config.getDateTimeFormatInstance();
protected void checkForDateFormat(final String iDateAsString) { if (iDateAsString != null) if (globalRef.getType() == OType.DATE) { try { getDatabase().getStorage().getConfiguration().getDateFormatInstance().parse(iDateAsString); } catch (ParseException e) { throw OException .wrapException(new OSchemaException("Invalid date format while formatting date '" + iDateAsString + "'"), e); } } else if (globalRef.getType() == OType.DATETIME) { try { getDatabase().getStorage().getConfiguration().getDateTimeFormatInstance().parse(iDateAsString); } catch (ParseException e) { throw OException .wrapException(new OSchemaException("Invalid datetime format while formatting date '" + iDateAsString + "'"), e); } } }
try { final SimpleDateFormat dateFormat = db != null ? db.getStorage().getConfiguration().getDateTimeFormatInstance() : new SimpleDateFormat(OStorageConfiguration.DEFAULT_DATETIME_FORMAT);
try { final SimpleDateFormat dateFormat = db != null ? db.getStorage().getConfiguration().getDateTimeFormatInstance() : new SimpleDateFormat(OStorageConfiguration.DEFAULT_DATETIME_FORMAT);
try { if (fieldValue != null && ((Date) fieldValue).before(getDatabase().getStorage().getConfiguration().getDateTimeFormatInstance() .parse(min))) validatable.error(newValidationError("minviolationDate", "min", min)); try { if (fieldValue != null && ((Date) fieldValue).before(getDatabase().getStorage().getConfiguration().getDateTimeFormatInstance() .parse(max))) validatable.error(newValidationError("maxviolationDate", "max", max));
try { if (fieldValue != null && ((Date) fieldValue).before(getDatabase().getStorage().getConfiguration().getDateTimeFormatInstance() .parse(min))) validatable.error(newValidationError("minviolationDate", "min", min)); try { if (fieldValue != null && ((Date) fieldValue).before(getDatabase().getStorage().getConfiguration().getDateTimeFormatInstance() .parse(max))) validatable.error(newValidationError("maxviolationDate", "max", max));