/** * Converts a <tt>java.util.Date</tt> into an <tt>org.tentackle.misc.Date</tt>. * * @param date the util date * @return the sql date, null if date was null */ public static Date toDate(java.util.Date date) { return date == null ? null : new Date(date.getTime()); }
@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.LocalDate</code> in the Java programming language. * * @param timezone the calendar providing the timezone configuration * @param mapNull true if 1.1.1970 should be mapped to null * @return the column value; if the value is SQL <code>NULL</code>, the * value returned is <code>null</code> */ public LocalDate getLocalDate(Calendar timezone, boolean mapNull) { Date date = getDate(timezone, mapNull); return date == null ? null : date.toLocalDate(); }
/** * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as * a <code>java.sql.Date</code> in the Java programming language. * * @param pos the parameter index in the result set * @param timezone the calendar providing the timezone configuration * @param mapNull true if 1.1.1970 should be mapped to null * @return the column value; if the value is SQL <code>NULL</code>, the * value returned is <code>null</code> */ public Date getDate(int pos, Calendar timezone, boolean mapNull) { try { java.sql.Date date = timezone == null ? resources.rs.getDate(pos + columnOffset) : resources.rs.getDate(pos + columnOffset, timezone); if (date == null || (mapNull && date.equals(DateHelper.MIN_DATE))) { // mindate is translated back to null return null; } return Date.createFrozen(date.getTime()); } catch (SQLException e) { throw new PersistenceException(resources.db, e); } }
/** * Save the state of this object to a stream. * * @serialData the value YYYYMMDD is emitted. This allows serializing * and deserializing in different timezones without changing the date. * @param s the stream * @throws IOException if writing to stream failed */ private void writeObject(ObjectOutputStream s) throws IOException { s.writeShort(getCalendar().get(Calendar.YEAR)); s.writeByte(getCalendar().get(Calendar.MONTH)); s.writeByte(getCalendar().get(Calendar.DAY_OF_MONTH)); s.writeBoolean(frozen); }
/** * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as * a <code>java.time.LocalDate</code> in the Java programming language. * * @param pos the parameter index in the result set * @param timezone the calendar providing the timezone configuration * @param mapNull true if 1.1.1970 should be mapped to null * @return the column value; if the value is SQL <code>NULL</code>, the * value returned is <code>null</code> */ public LocalDate getLocalDate(int pos, Calendar timezone, boolean mapNull) { Date date = getDate(pos, timezone, mapNull); return date == null ? null : date.toLocalDate(); }
/** * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as * a <code>java.sql.Date</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 * @param mapNull true if 1.1.1970 should be mapped to null * @return the column value; if the value is SQL <code>NULL</code>, the * value returned is <code>null</code> */ public Date getDate(String name, Calendar timezone, boolean mapNull) { try { java.sql.Date date = timezone == null ? resources.rs.getDate(name) : resources.rs.getDate(name, timezone); if (date == null || (mapNull && date.equals(DateHelper.MIN_DATE))) { // mindate is translated back to null return null; } return Date.createFrozen(date.getTime()); } catch (SQLException e) { throw new PersistenceException(resources.db, e); } }
/** * Gets the current date. * * @return current Date */ public static Date today() { return new Date(System.currentTimeMillis()); }
@Deprecated @Override public void setMinutes(int minutes) { assertNotFrozen(); super.setMinutes(minutes); }
/** * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as * a <code>java.time.LocalDate</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 * @param mapNull true if 1.1.1970 should be mapped to null * @return the column value; if the value is SQL <code>NULL</code>, the * value returned is <code>null</code> */ public LocalDate getLocalDate(String name, Calendar timezone, boolean mapNull) { Date date = getDate(name, timezone, mapNull); return date == null ? null : date.toLocalDate(); }
/** * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as * a <code>java.sql.Date</code> in the Java programming language. * * @param timezone the calendar providing the timezone configuration * @param mapNull true if 1.1.1970 should be mapped to null * @return the column value; if the value is SQL <code>NULL</code>, the * value returned is <code>null</code> */ public Date getDate(Calendar timezone, boolean mapNull) { try { int pos = nextConfiguredIndex(); java.sql.Date date = timezone == null ? resources.rs.getDate(pos + columnOffset) : resources.rs.getDate(pos + columnOffset, timezone); if (date == null || (mapNull && date.equals(DateHelper.MIN_DATE))) { // mindate is translated back to null return null; } return Date.createFrozen(date.getTime()); } catch (SQLException e) { throw new PersistenceException(resources.db, e); } }
/** * Converts a Calendar into a org.tentackle.misc.Date. * * @param cal the calendar * @return the date, null if cal was null */ public static Date toDate(Calendar cal) { return cal == null ? null : new Date(cal.getTime().getTime()); }
@Deprecated @Override public void setDate(int date) { assertNotFrozen(); super.setDate(date); }
/** * Gets the current date with an offset. * * @param dayOffset the offset in days * @param monthOffset the offset in months * @param yearOffset the offset in years * @return the date */ public static Date today(int dayOffset, int monthOffset, int yearOffset) { GregorianCalendar cal = new GregorianCalendar(); cal.add(GregorianCalendar.DATE, dayOffset); cal.add(GregorianCalendar.MONTH, monthOffset); cal.add(GregorianCalendar.YEAR, yearOffset); return new Date(cal.getTimeInMillis()); }
@Deprecated @Override public void setSeconds(int seconds) { assertNotFrozen(); super.setSeconds(seconds); }
/** * Parses a short date. * * @param str the string to parse * @return the date * @throws ParseException if parsing failed */ public static synchronized org.tentackle.common.Date parseShortDate(String str) throws ParseException { return new org.tentackle.common.Date(getFormatting().shortDateFormat.parse(str).getTime()); }
/** * {@inheritDoc} * <p> * Overridden to clear the lazy calendar and to check for frozen. */ @Override public void setTime(long date) { assertNotFrozen(); super.setTime(date); cal = null; }
/** * Gets the SQL-Date. * * @return the org.tentackle.misc.Date, null if field is empty */ @Override public org.tentackle.common.Date getDate() { Date date = getFormValue(); return date == null ? null : new org.tentackle.common.Date(date.getTime()); }
@Deprecated @Override public void setMonth(int month) { assertNotFrozen(); super.setMonth(month); }