/** * Gets the current time. * * @return current Time */ public static Time daytime() { return new Time(System.currentTimeMillis()); }
@Deprecated @Override public void setYear(int year) { assertNotFrozen(); super.setYear(year); }
/** * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as * a <code>java.time.LocalTime</code> in the Java programming language. * * @param pos the parameter index in the result set * @param timezone the calendar providing the timezone configuration * @return the column value; if the value is SQL <code>NULL</code>, the * value returned is <code>null</code> */ public LocalTime getLocalTime(int pos, Calendar timezone) { Time time = getTime(pos, timezone); return time == null ? null : time.toLocalTime(); }
/** * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as * a <code>java.sql.Time</code> in the Java programming language. * * @param pos the parameter index in the result set * @param timezone the calendar providing the timezone configuration * @return the column value; if the value is SQL <code>NULL</code>, the * value returned is <code>null</code> */ public Time getTime(int pos, Calendar timezone) { try { // no mapNull possible java.sql.Time time = timezone == null ? resources.rs.getTime(pos + columnOffset) : resources.rs.getTime(pos + columnOffset, timezone); return time == null ? null : Time.createFrozen(time.getTime()); } catch (SQLException e) { throw new PersistenceException(resources.db, e); } }
/** * Save the state of this object to a stream. * * @serialData the value HHMMSSsss is emitted. This allows serializing * and deserializing in different timezones without changing the time. * @param s the stream * @throws IOException if writing to stream failed */ private void writeObject(ObjectOutputStream s) throws IOException { s.writeByte(getCalendar().get(Calendar.HOUR_OF_DAY)); s.writeByte(getCalendar().get(Calendar.MINUTE)); s.writeByte(getCalendar().get(Calendar.SECOND)); s.writeShort(getCalendar().get(Calendar.MILLISECOND)); s.writeBoolean(frozen); }
@Deprecated @Override public void setMonth(int month) { assertNotFrozen(); super.setMonth(month); }
/** * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as * a <code>java.time.LocalTime</code> in the Java programming language. * * @param timezone the calendar providing the timezone configuration * @return the column value; if the value is SQL <code>NULL</code>, the * value returned is <code>null</code> */ public LocalTime getLocalTime(Calendar timezone) { Time time = getTime(timezone); return time == null ? null : time.toLocalTime(); }
/** * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as * a <code>java.sql.Time</code> in the Java programming language. * * @param name the label for the column specified with the SQL AS clause. * If the SQL AS clause was not specified, then the label is the name of the column * @param timezone the calendar providing the timezone configuration * @return the column value; if the value is SQL <code>NULL</code>, the * value returned is <code>null</code> */ public Time getTime(String name, Calendar timezone) { try { // no minTime (makes no sense, see PreparedStatementWrapper) java.sql.Time time = timezone == null ? resources.rs.getTime(name) : resources.rs.getTime(name, timezone); return time == null ? null : Time.createFrozen(time.getTime()); } catch (SQLException e) { throw new PersistenceException(resources.db, e); } }
/** * Converts a java.util.Date into a org.tentackle.misc.Time. * * @param date the date * @return the time of the day in date, null if date was null */ public static Time toTime(java.util.Date date) { return date == null ? null : new Time(date.getTime()); }
@Deprecated @Override public void setDate(int date) { assertNotFrozen(); super.setDate(date); }
/** * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as * a <code>java.time.LocalTime</code> in the Java programming language. * * @param name the label for the column specified with the SQL AS clause. * If the SQL AS clause was not specified, then the label is the name of the column * @param timezone the calendar providing the timezone configuration * @return the column value; if the value is SQL <code>NULL</code>, the * value returned is <code>null</code> */ public LocalTime getLocalTime(String name, Calendar timezone) { Time time = getTime(name, timezone); return time == null ? null : time.toLocalTime(); }
/** * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as * a <code>java.sql.Time</code> in the Java programming language. * * @param timezone the calendar providing the timezone configuration * @return the column value; if the value is SQL <code>NULL</code>, the * value returned is <code>null</code> */ public Time getTime(Calendar timezone) { try { // no mapNull possible int pos = nextConfiguredIndex(); java.sql.Time time = timezone == null ? resources.rs.getTime(pos + columnOffset) : resources.rs.getTime(pos + columnOffset, timezone); return time == null ? null : Time.createFrozen(time.getTime()); } catch (SQLException e) { throw new PersistenceException(resources.db, e); } }
/** * Converts a Calendar into a org.tentackle.misc.Time. * * @param cal the calendar * @return the time of day, null if cal was null */ public static Time toTime(Calendar cal) { return cal == null ? null : new Time(cal.getTime().getTime()); }
@Deprecated @Override public void setHours(int hours) { assertNotFrozen(); super.setHours(hours); }
/** * Parses a short time. * * @param str the string to parse * @return the time * @throws ParseException if parsing failed */ public static synchronized org.tentackle.common.Time parseShortTime(String str) throws ParseException { return new org.tentackle.common.Time(getFormatting().shortTimeFormat.parse(str).getTime()); }
@Deprecated @Override public void setMinutes(int minutes) { assertNotFrozen(); super.setMinutes(minutes); }
/** * Gets the current time with an offset. * * @param hourOffset the offset in hours * @param minuteOffset the offset in minutes * @param secondOffset the offset in seconds * @return the time */ public static Time daytime(int secondOffset, int minuteOffset, int hourOffset) { GregorianCalendar cal = new GregorianCalendar(); cal.add(GregorianCalendar.SECOND, secondOffset); cal.add(GregorianCalendar.MINUTE, minuteOffset); cal.add(GregorianCalendar.HOUR, hourOffset); return new Time(cal.getTimeInMillis()); }
@Deprecated @Override public void setSeconds(int seconds) { assertNotFrozen(); super.setSeconds(seconds); }
/** * Parses a time. * * @param str the string to parse * @return the time * @throws ParseException if parsing failed */ public static synchronized org.tentackle.common.Time parseTime(String str) throws ParseException { return new org.tentackle.common.Time(getFormatting().timeFormat.parse(str).getTime()); }