Here you can find the source of parseAsCassandraTimestamp(String dateString)
Parameter | Description |
---|---|
dateString | a parameter |
Parameter | Description |
---|---|
ParseException | an exception |
public static Date parseAsCassandraTimestamp(String dateString) throws ParseException
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String[] CASSANDRA_TS_PATTERNS = new String[] { "yyyy-mm-dd HH:mm", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mmZ", "yyyy-MM-dd HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm", "yyyy-MM-dd'T'HH:mmZ", "yyyy-MM-dd'T'HH:mm:ss", "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd", "yyyy-MM-ddZ" }; /**//from ww w . j a va2s .com * * @param dateString * @return * @throws ParseException */ public static Date parseAsCassandraTimestamp(String dateString) throws ParseException { SimpleDateFormat parser = new SimpleDateFormat(); parser.setLenient(false); for (String pattern : CASSANDRA_TS_PATTERNS) { parser.applyPattern(pattern); try { return parser.parse(dateString); } catch (ParseException e) { } } throw new ParseException("Unable to parse as date [" + dateString + "]", -1); } }