/** * Transform a {@link Duration} into a {@link DayToSecond} interval by * taking its number of milliseconds. */ public static DayToSecond valueOf(Duration duration) { return duration == null ? null : valueOf(duration.toMillis()); }
@Override final DayToSecond get0(BindingGetSQLInputContext<U> ctx) throws SQLException { String string = ctx.input().readString(); return string == null ? null : DayToSecond.valueOf(string); }
private static final Interval parseIntervalLiteral(ParserContext ctx) { String string = parseStringLiteral(ctx); DayToSecond ds = DayToSecond.valueOf(string); if (ds != null) return ds; YearToMonth ym = YearToMonth.valueOf(string); if (ym != null) return ym; throw ctx.exception("Illegal interval literal"); }
/** * Parse a string representation of a <code>INTERVAL DAY TO SECOND</code> * * @param string A string representation of the form * <code>[+|-][days] [hours]:[minutes]:[seconds].[fractional seconds]</code> * @return The parsed <code>INTERVAL DAY TO SECOND</code> object, or * <code>null</code> if the string could not be parsed. */ public static DayToSecond valueOf(String string) { if (string != null) { // Accept also doubles as the number of days try { return valueOf(Double.valueOf(string)); } catch (NumberFormatException e) { Matcher matcher = PATTERN.matcher(string); if (matcher.find()) { boolean negative = "-".equals(matcher.group(1)); int days = Convert.convert(matcher.group(2), int.class); int hours = Convert.convert(matcher.group(3), int.class); int minutes = Convert.convert(matcher.group(4), int.class); int seconds = Convert.convert(matcher.group(5), int.class); int nano = Convert.convert(StringUtils.rightPad(matcher.group(6), 9, "0"), int.class); return new DayToSecond(days, hours, minutes, seconds, nano, negative); } } } return null; }
@Override final DayToSecond get0(BindingGetStatementContext<U> ctx) throws SQLException { if ( ctx.family() == POSTGRES) { Object object = ctx.statement().getObject(ctx.index()); return object == null ? null : PostgresUtils.toDayToSecond(object); } else { String string = ctx.statement().getString(ctx.index()); return string == null ? null : DayToSecond.valueOf(string); } }
@Override final DayToSecond get0(BindingGetResultSetContext<U> ctx) throws SQLException { if ( ctx.family() == POSTGRES) { Object object = ctx.resultSet().getObject(ctx.index()); return object == null ? null : PostgresUtils.toDayToSecond(object); } else { String string = ctx.resultSet().getString(ctx.index()); return string == null ? null : DayToSecond.valueOf(string); } }
return (T) (string == null ? null : DayToSecond.valueOf(string));
return (T) (string == null ? null : DayToSecond.valueOf(string));
return (T) (string == null ? null : DayToSecond.valueOf(string));