< prev index next >

src/java.desktop/share/classes/javax/print/attribute/DateTimeSyntax.java

Print this page

        

*** 32,86 **** /** * Class DateTimeSyntax is an abstract base class providing the common * implementation of all attributes whose value is a date and time. * <P> ! * Under the hood, a date-time attribute is stored as a value of class <code> ! * java.util.Date</code>. You can get a date-time attribute's Date value by * calling {@link #getValue() getValue()}. A date-time attribute's * Date value is established when it is constructed (see {@link * #DateTimeSyntax(Date) DateTimeSyntax(Date)}). Once * constructed, a date-time attribute's value is immutable. * <P> * To construct a date-time attribute from separate values of the year, month, ! * day, hour, minute, and so on, use a <code>java.util.Calendar</code> ! * object to construct a <code>java.util.Date</code> object, then use the ! * <code>java.util.Date</code> object to construct the date-time attribute. * To convert * a date-time attribute to separate values of the year, month, day, hour, ! * minute, and so on, create a <code>java.util.Calendar</code> object and ! * set it to the <code>java.util.Date</code> from the date-time attribute. Class ! * DateTimeSyntax stores its value in the form of a <code>java.util.Date ! * </code> ! * rather than a <code>java.util.Calendar</code> because it typically takes ! * less memory to store and less time to compare a <code>java.util.Date</code> ! * than a <code>java.util.Calendar</code>. * * @author Alan Kaminsky */ public abstract class DateTimeSyntax implements Serializable, Cloneable { private static final long serialVersionUID = -1400819079791208582L; // Hidden data members. /** ! * This date-time attribute's<code>java.util.Date</code> value. * @serial */ private Date value; // Hidden constructors. /** * Construct a new date-time attribute with the given ! * <code>java.util.Date </code> value. * ! * @param value <code>java.util.Date</code> value. * * @exception NullPointerException ! * (unchecked exception) Thrown if <CODE>theValue</CODE> is null. */ protected DateTimeSyntax(Date value) { if (value == null) { throw new NullPointerException("value is null"); } --- 32,85 ---- /** * Class DateTimeSyntax is an abstract base class providing the common * implementation of all attributes whose value is a date and time. * <P> ! * Under the hood, a date-time attribute is stored as a value of class ! * {@code java.util.Date}. You can get a date-time attribute's Date value by * calling {@link #getValue() getValue()}. A date-time attribute's * Date value is established when it is constructed (see {@link * #DateTimeSyntax(Date) DateTimeSyntax(Date)}). Once * constructed, a date-time attribute's value is immutable. * <P> * To construct a date-time attribute from separate values of the year, month, ! * day, hour, minute, and so on, use a {@code java.util.Calendar} ! * object to construct a {@code java.util.Date} object, then use the ! * {@code java.util.Date} object to construct the date-time attribute. * To convert * a date-time attribute to separate values of the year, month, day, hour, ! * minute, and so on, create a {@code java.util.Calendar} object and ! * set it to the {@code java.util.Date} from the date-time attribute. Class ! * DateTimeSyntax stores its value in the form of a {@code java.util.Date} ! * rather than a {@code java.util.Calendar} because it typically takes ! * less memory to store and less time to compare a {@code java.util.Date} ! * than a {@code java.util.Calendar}. * * @author Alan Kaminsky */ public abstract class DateTimeSyntax implements Serializable, Cloneable { private static final long serialVersionUID = -1400819079791208582L; // Hidden data members. /** ! * This date-time attribute's {@code java.util.Date} value. * @serial */ private Date value; // Hidden constructors. /** * Construct a new date-time attribute with the given ! * {@code java.util.Date} value. * ! * @param value {@code java.util.Date} value. * * @exception NullPointerException ! * (unchecked exception) Thrown if {@code theValue} is null. */ protected DateTimeSyntax(Date value) { if (value == null) { throw new NullPointerException("value is null"); }
*** 88,98 **** } // Exported operations. /** ! * Returns this date-time attribute's <code>java.util.Date</code> * value. * @return the Date. */ public Date getValue() { return new Date (value.getTime()); --- 87,97 ---- } // Exported operations. /** ! * Returns this date-time attribute's {@code java.util.Date} * value. * @return the Date. */ public Date getValue() { return new Date (value.getTime());
*** 103,143 **** /** * Returns whether this date-time attribute is equivalent to the passed in * object. To be equivalent, all of the following conditions must be true: * <OL TYPE=1> * <LI> ! * <CODE>object</CODE> is not null. * <LI> ! * <CODE>object</CODE> is an instance of class DateTimeSyntax. * <LI> ! * This date-time attribute's <code>java.util.Date</code> value and ! * <CODE>object</CODE>'s <code>java.util.Date</code> value are * equal. </OL> * * @param object Object to compare to. * ! * @return True if <CODE>object</CODE> is equivalent to this date-time * attribute, false otherwise. */ public boolean equals(Object object) { return (object != null && object instanceof DateTimeSyntax && value.equals(((DateTimeSyntax) object).value)); } /** * Returns a hash code value for this date-time attribute. The hashcode is ! * that of this attribute's <code>java.util.Date</code> value. */ public int hashCode() { return value.hashCode(); } /** * Returns a string value corresponding to this date-time attribute. * The string value is just this attribute's ! * <code>java.util.Date</code> value * converted to a string. */ public String toString() { return "" + value; } --- 102,142 ---- /** * Returns whether this date-time attribute is equivalent to the passed in * object. To be equivalent, all of the following conditions must be true: * <OL TYPE=1> * <LI> ! * {@code object} is not null. * <LI> ! * {@code object} is an instance of class DateTimeSyntax. * <LI> ! * This date-time attribute's {@code java.util.Date} value and ! * {@code object}'s {@code java.util.Date} value are * equal. </OL> * * @param object Object to compare to. * ! * @return True if {@code object} is equivalent to this date-time * attribute, false otherwise. */ public boolean equals(Object object) { return (object != null && object instanceof DateTimeSyntax && value.equals(((DateTimeSyntax) object).value)); } /** * Returns a hash code value for this date-time attribute. The hashcode is ! * that of this attribute's {@code java.util.Date} value. */ public int hashCode() { return value.hashCode(); } /** * Returns a string value corresponding to this date-time attribute. * The string value is just this attribute's ! * {@code java.util.Date} value * converted to a string. */ public String toString() { return "" + value; }
< prev index next >