KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > types > DateTimeDataValue


1 /*
2
3    Derby - Class org.apache.derby.iapi.types.DateTimeDataValue
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.iapi.types;
23
24 import org.apache.derby.iapi.error.StandardException;
25
26 public interface DateTimeDataValue extends DataValueDescriptor
27 {
28     public static final int YEAR_FIELD = 0;
29     public static final int MONTH_FIELD = 1;
30     public static final int DAY_FIELD = 2;
31     public static final int HOUR_FIELD = 3;
32     public static final int MINUTE_FIELD = 4;
33     public static final int SECOND_FIELD = 5;
34
35     // The JDBC interval types
36
public static final int FRAC_SECOND_INTERVAL = 0;
37     public static final int SECOND_INTERVAL = 1;
38     public static final int MINUTE_INTERVAL = 2;
39     public static final int HOUR_INTERVAL = 3;
40     public static final int DAY_INTERVAL = 4;
41     public static final int WEEK_INTERVAL = 5;
42     public static final int MONTH_INTERVAL = 6;
43     public static final int QUARTER_INTERVAL = 7;
44     public static final int YEAR_INTERVAL = 8;
45
46     /**
47      * Get the year number out of a date.
48      *
49      * @param result The result of the previous call to this method, null
50      * if not called yet.
51      *
52      * @return A NumberDataValue containing the year number.
53      *
54      * @exception StandardException Thrown on error
55      */

56     NumberDataValue getYear(NumberDataValue result)
57                             throws StandardException;
58
59     /**
60      * Get the month number out of a date.
61      *
62      * @param result The result of the previous call to this method, null
63      * if not called yet.
64      *
65      * @return A NumberDataValue containing the month number.
66      *
67      * @exception StandardException Thrown on error
68      */

69     NumberDataValue getMonth(NumberDataValue result)
70                             throws StandardException;
71
72     /**
73      * Get the day of the month.
74      *
75      * @param result The result of the previous call to this method, null
76      * if not called yet.
77      *
78      * @return A NumberDataValue containing the day of the month.
79      *
80      * @exception StandardException Thrown on error
81      */

82     NumberDataValue getDate(NumberDataValue result)
83                             throws StandardException;
84
85     /**
86      * Get the hour of the day out of a time or timestamp.
87      *
88      * @param result The result of the previous call to this method, null
89      * if not called yet.
90      *
91      * @return A NumberDataValue containing the hour of the day.
92      *
93      * @exception StandardException Thrown on error
94      */

95     NumberDataValue getHours(NumberDataValue result)
96                             throws StandardException;
97
98     /**
99      * Get the minute of the hour out of a time or timestamp.
100      *
101      * @param result The result of the previous call to this method, null
102      * if not called yet.
103      *
104      * @return A NumberDataValue containing the minute of the hour.
105      *
106      * @exception StandardException Thrown on error
107      */

108     NumberDataValue getMinutes(NumberDataValue result)
109                             throws StandardException;
110
111     /**
112      * Get the second of the minute out of a time or timestamp.
113      *
114      * @param result The result of the previous call to this method, null
115      * if not called yet.
116      *
117      * @return A NumberDataValue containing the second of the minute.
118      *
119      * @exception StandardException Thrown on error
120      */

121     NumberDataValue getSeconds(NumberDataValue result)
122                             throws StandardException;
123
124     /**
125      * Add a number of intervals to a datetime value. Implements the JDBC escape TIMESTAMPADD function.
126      *
127      * @param intervalType One of FRAC_SECOND_INTERVAL, SECOND_INTERVAL, MINUTE_INTERVAL, HOUR_INTERVAL,
128      * DAY_INTERVAL, WEEK_INTERVAL, MONTH_INTERVAL, QUARTER_INTERVAL, or YEAR_INTERVAL
129      * @param intervalCount The number of intervals to add
130      * @param currentDate Used to convert time to timestamp
131      * @param resultHolder If non-null a DateTimeDataValue that can be used to hold the result. If null then
132      * generate a new holder
133      *
134      * @return startTime + intervalCount intervals, as a timestamp
135      *
136      * @exception StandardException
137      */

138     DateTimeDataValue timestampAdd( int intervalType,
139                                     NumberDataValue intervalCount,
140                                     java.sql.Date JavaDoc currentDate,
141                                     DateTimeDataValue resultHolder)
142         throws StandardException;
143
144     /**
145      * Finds the difference between two datetime values as a number of intervals. Implements the JDBC
146      * TIMESTAMPDIFF escape function.
147      *
148      * @param intervalType One of FRAC_SECOND_INTERVAL, SECOND_INTERVAL, MINUTE_INTERVAL, HOUR_INTERVAL,
149      * DAY_INTERVAL, WEEK_INTERVAL, MONTH_INTERVAL, QUARTER_INTERVAL, or YEAR_INTERVAL
150      * @param time1
151      * @param currentDate Used to convert time to timestamp
152      * @param resultHolder If non-null a DateTimeDataValue that can be used to hold the result. If null then
153      * generate a new holder
154      *
155      * @return the number of intervals by which this datetime is greater than time1
156      *
157      * @exception StandardException
158      */

159     NumberDataValue timestampDiff( int intervalType,
160                                    DateTimeDataValue time1,
161                                    java.sql.Date JavaDoc currentDate,
162                                    NumberDataValue resultHolder)
163         throws StandardException;
164 }
165
166
Popular Tags