com.amazonaws.util.DateUtils Java Examples
The following examples show how to use
com.amazonaws.util.DateUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Utilities.java From amazon-cognito-developer-authentication-sample with Apache License 2.0 | 6 votes |
/** * Checks to see if the request has valid timestamp. If given timestamp * falls in 30 mins window from current server timestamp */ public static boolean isTimestampValid(String timestamp) { long timestampLong = 0L; final long window = 15 * 60 * 1000L; if (null == timestamp) { return false; } timestampLong = DateUtils.parseISO8601Date(timestamp).getTime(); Long now = new Date().getTime(); long before15Mins = new Date(now - window).getTime(); long after15Mins = new Date(now + window).getTime(); return (timestampLong >= before15Mins && timestampLong <= after15Mins); }
Example #2
Source File: Utilities.java From reinvent2013-mobile-photo-share with Apache License 2.0 | 6 votes |
/** * Checks to see if the request has valid timestamp. If given timestamp * falls in 30 mins window from current server timestamp */ public static boolean isTimestampValid(String timestamp) { long timestampLong = 0L; final long window = 15 * 60 * 1000L; if (null == timestamp) { return false; } try { timestampLong = new DateUtils().parseIso8601Date(timestamp).getTime(); } catch (ParseException exception) { log.warning("Error parsing timestamp sent from client : " + timestamp); return false; } Long now = new Date().getTime(); long before15Mins = new Date(now - window).getTime(); long after15Mins = new Date(now + window).getTime(); return (timestampLong >= before15Mins && timestampLong <= after15Mins); }
Example #3
Source File: XmlResponsesSaxParser.java From flink with Apache License 2.0 | 5 votes |
@Override protected void doEndElement(String uri, String name, String qName) { if (in("ListAllMyBucketsResult", "Owner")) { if (name.equals("ID")) { bucketsOwner.setId(getText()); } else if (name.equals("DisplayName")) { bucketsOwner.setDisplayName(getText()); } } else if (in("ListAllMyBucketsResult", "Buckets")) { if (name.equals("Bucket")) { buckets.add(currentBucket); currentBucket = null; } } else if (in("ListAllMyBucketsResult", "Buckets", "Bucket")) { if (name.equals("Name")) { currentBucket.setName(getText()); } else if (name.equals("CreationDate")) { Date creationDate = DateUtils.parseISO8601Date(getText()); currentBucket.setCreationDate(creationDate); } } }
Example #4
Source File: DynamoDBUnmarshallerUtil.java From Cheddar with Apache License 2.0 | 5 votes |
public static SSUnmarshaller getDateSSUnmarshaller() { return new SSUnmarshaller() { @Override public Object unmarshall(final AttributeValue value) throws ParseException { final Set<Date> argument = new HashSet<Date>(); for (final String s : value.getSS()) { argument.add(DateUtils.parseISO8601Date(s)); } return argument; } }; }
Example #5
Source File: DynamoDBUnmarshallerUtil.java From Cheddar with Apache License 2.0 | 5 votes |
public static SUnmarshaller getDateSUnmarshaller() { return new SUnmarshaller() { @Override public Object unmarshall(final AttributeValue value) throws ParseException { return DateUtils.parseISO8601Date(value.getS()); } }; }
Example #6
Source File: DynamoDBUnmarshallerUtil.java From Cheddar with Apache License 2.0 | 5 votes |
public static SSUnmarshaller getCalendarSSUnmarshaller() { return new SSUnmarshaller() { @Override public Object unmarshall(final AttributeValue value) throws ParseException { final Set<Calendar> argument = new HashSet<Calendar>(); for (final String s : value.getSS()) { final Calendar cal = GregorianCalendar.getInstance(); cal.setTime(DateUtils.parseISO8601Date(s)); argument.add(cal); } return argument; } }; }
Example #7
Source File: DynamoDBUnmarshallerUtil.java From Cheddar with Apache License 2.0 | 5 votes |
public static SUnmarshaller getCalendarSUnmarshaller() { return new SUnmarshaller() { @Override public Object unmarshall(final AttributeValue value) throws ParseException { final Calendar cal = GregorianCalendar.getInstance(); cal.setTime(DateUtils.parseISO8601Date(value.getS())); return cal; } }; }