Path: blob/master/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCreation.java
41171 views
/*1* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.print.attribute.standard;2627import java.io.Serial;28import java.util.Calendar;29import java.util.Date;3031import javax.print.attribute.Attribute;32import javax.print.attribute.DateTimeSyntax;33import javax.print.attribute.PrintJobAttribute;3435/**36* Class {@code DateTimeAtCreation} is a printing attribute class, a date-time37* attribute, that indicates the date and time at which the Print Job was38* created.39* <p>40* To construct a {@code DateTimeAtCreation} attribute from separate values of41* the year, month, day, hour, minute, and so on, use a42* {@link Calendar Calendar} object to construct a {@link Date Date} object,43* then use the {@link Date Date} object to construct the DateTimeAtCreation44* attribute. To convert a {@code DateTimeAtCreation} attribute to separate45* values of the year, month, day, hour, minute, and so on, create a46* {@link Calendar Calendar} object and set it to the {@link Date Date} from the47* {@code DateTimeAtCreation} attribute.48* <p>49* <b>IPP Compatibility:</b> The information needed to construct an IPP50* "date-time-at-creation" attribute can be obtained as described above. The51* category name returned by {@code getName()} gives the IPP attribute name.52*53* @author Alan Kaminsky54*/55public final class DateTimeAtCreation extends DateTimeSyntax56implements PrintJobAttribute {5758/**59* Use serialVersionUID from JDK 1.4 for interoperability.60*/61@Serial62private static final long serialVersionUID = -2923732231056647903L;6364/**65* Construct a new date-time at creation attribute with the given66* {@link Date Date} value.67*68* @param dateTime {@link Date Date} value69* @throws NullPointerException if {@code dateTime} is {@code null}70*/71public DateTimeAtCreation(Date dateTime) {72super (dateTime);73}7475/**76* Returns whether this date-time at creation attribute is equivalent to the77* passed in object. To be equivalent, all of the following conditions must78* be true:79* <ol type=1>80* <li>{@code object} is not {@code null}.81* <li>{@code object} is an instance of class {@code DateTimeAtCreation}.82* <li>This date-time at creation attribute's {@link Date Date}83* value and {@code object}'s {@link Date Date} value are equal.84* </ol>85*86* @param object {@code Object} to compare to87* @return {@code true} if {@code object} is equivalent to this date-time at88* creation attribute, {@code false} otherwise89*/90public boolean equals(Object object) {91return(super.equals (object) &&92object instanceof DateTimeAtCreation);93}9495/**96* Get the printing attribute class which is to be used as the "category"97* for this printing attribute value.98* <p>99* For class {@code DateTimeAtCreation}, the category is class100* {@code DateTimeAtCreation} itself.101*102* @return printing attribute class (category), an instance of class103* {@link Class java.lang.Class}104*/105public final Class<? extends Attribute> getCategory() {106return DateTimeAtCreation.class;107}108109/**110* Get the name of the category of which this attribute value is an111* instance.112* <p>113* For class {@code DateTimeAtCreation}, the category name is114* {@code "date-time-at-creation"}.115*116* @return attribute category name117*/118public final String getName() {119return "date-time-at-creation";120}121}122123124