@Override public Long parse(String value) { if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) return null; // enclosing single quotes required, even for long literals if (!ParseUtils.isQuoted(value)) throw new InvalidTypeException("time values must be enclosed by single quotes"); value = value.substring(1, value.length() - 1); if (ParseUtils.isLongLiteral(value)) { try { return Long.parseLong(value); } catch (NumberFormatException e) { throw new InvalidTypeException( String.format("Cannot parse time value from \"%s\"", value), e); } } try { return ParseUtils.parseTime(value); } catch (ParseException e) { throw new InvalidTypeException( String.format("Cannot parse time value from \"%s\"", value), e); } }
@Override public Long parse(String value) { if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) return null; // enclosing single quotes required, even for long literals if (!ParseUtils.isQuoted(value)) throw new InvalidTypeException("time values must be enclosed by single quotes"); value = value.substring(1, value.length() - 1); if (ParseUtils.isLongLiteral(value)) { try { return Long.parseLong(value); } catch (NumberFormatException e) { throw new InvalidTypeException(String.format("Cannot parse time value from \"%s\"", value), e); } } try { return ParseUtils.parseTime(value); } catch (ParseException e) { throw new InvalidTypeException(String.format("Cannot parse time value from \"%s\"", value), e); } }
@Override public Long parse(String value) { if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) return null; // enclosing single quotes required, even for long literals if (!ParseUtils.isQuoted(value)) throw new InvalidTypeException("time values must be enclosed by single quotes"); value = value.substring(1, value.length() - 1); if (ParseUtils.isLongLiteral(value)) { try { return Long.parseLong(value); } catch (NumberFormatException e) { throw new InvalidTypeException(String.format("Cannot parse time value from \"%s\"", value), e); } } try { return ParseUtils.parseTime(value); } catch (ParseException e) { throw new InvalidTypeException(String.format("Cannot parse time value from \"%s\"", value), e); } }
@Override public Long parse(String value) { if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) return null; // enclosing single quotes required, even for long literals if (!ParseUtils.isQuoted(value)) throw new InvalidTypeException("time values must be enclosed by single quotes"); value = value.substring(1, value.length() - 1); if (ParseUtils.isLongLiteral(value)) { try { return Long.parseLong(value); } catch (NumberFormatException e) { throw new InvalidTypeException(String.format("Cannot parse time value from \"%s\"", value), e); } } try { return ParseUtils.parseTime(value); } catch (ParseException e) { throw new InvalidTypeException(String.format("Cannot parse time value from \"%s\"", value), e); } }