List of usage examples for com.amazonaws.services.simpledb.util SimpleDBUtils decodeDate
public static Date decodeDate(String value) throws ParseException
From source file:com.aipo.aws.simpledb.ResultItem.java
License:Open Source License
public Date getAsDate(String key) { String value = get(key);/*from w ww . ja v a 2 s .c o m*/ if (value == null) { return null; } try { return SimpleDBUtils.decodeDate(value); } catch (ParseException e) { // ignore } return null; }
From source file:com.shelfmap.simplequery.domain.impl.DateAttributeConverter.java
License:Apache License
@Override public Date restoreValue(String targetValue) throws CanNotRestoreAttributeException { if (targetValue == null) return null; try {//from w w w. j a va 2 s . c o m return SimpleDBUtils.decodeDate(targetValue); } catch (ParseException ex) { throw new CanNotRestoreAttributeException(ex, targetValue, Date.class); } }
From source file:wwutil.jsoda.DataUtil.java
License:Mozilla Public License
/** Caller should handle custom valueType first before calling this. */ @SuppressWarnings("unchecked") static Object decodeAttrStrToValue(String attrStr, Class valueType) throws Exception { // Set null if input is null. if (attrStr == null) return null; if (valueType == String.class) return attrStr; // Return string type as it is. // non-String field having "" is treated as null. if (attrStr.equals("")) return null; if (valueType == Byte.class || valueType == byte.class) { return new Byte((byte) SimpleDBUtils.decodeZeroPaddingInt(attrStr)); } else if (valueType == Short.class || valueType == short.class) { return new Short((short) SimpleDBUtils.decodeZeroPaddingInt(attrStr)); } else if (valueType == Integer.class || valueType == int.class) { return new Integer(SimpleDBUtils.decodeZeroPaddingInt(attrStr)); } else if (valueType == Long.class || valueType == long.class) { return new Long(SimpleDBUtils.decodeZeroPaddingLong(attrStr)); } else if (valueType == Float.class || valueType == float.class) { return new Float(SimpleDBUtils.decodeZeroPaddingFloat(attrStr)); } else if (valueType == Double.class || valueType == double.class) { return new Double(attrStr); } else if (valueType == Boolean.class || valueType == boolean.class) { return new Boolean(attrStr); } else if (valueType == Character.class || valueType == char.class) { return attrStr.charAt(0); } else if (valueType == Date.class) { return SimpleDBUtils.decodeDate(attrStr); } else if (valueType.isEnum()) { return Enum.valueOf(valueType, attrStr); }/*from w ww .ja v a 2 s . c om*/ // de-JSONify the rest. return fromJson(attrStr, valueType); }