KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > write > DateTime


1 /*********************************************************************
2 *
3 * Copyright (C) 2001 Andrew Khan
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ***************************************************************************/

19
20 package jxl.write;
21
22 import java.util.Date JavaDoc;
23
24 import jxl.DateCell;
25 import jxl.write.biff.DateRecord;
26 import jxl.format.CellFormat;
27
28 /**
29  * A Date which may be created on the fly by a user application and added to a
30  * spreadsheet
31  *
32  * NOTE: By default, all dates will have local timezone information added to
33  * their UTC value. If this is not desired (eg. if the date entered
34  * represents an interval eg. 9.83s for the 100m world record, then use
35  * the overloaded constructor which indicate that the date passed in was
36  * created under the GMT timezone. It is important that when the date
37  * was created, an instruction like
38  * Calendar.setTimeZone(TimeZone.getTimeZone("GMT"))
39  * was made prior to that
40  */

41 public class DateTime extends DateRecord implements WritableCell, DateCell
42 {
43   /**
44    * Instance variable for dummy variable overload
45    */

46   public static final GMTDate GMT = new GMTDate();
47
48   /**
49    * Constructor
50    *
51    * @param c the column
52    * @param r the row
53    * @param d the date
54    */

55   public DateTime(int c, int r, Date JavaDoc d)
56   {
57     super(c, r, d);
58   }
59
60   /**
61    * Constructor, which adjusts the specified date to take timezone
62    * considerations into account
63    *
64    * @param c the column
65    * @param r the row
66    * @param d the date
67    * @param a dummy overload
68    */

69   public DateTime(int c, int r, Date JavaDoc d, GMTDate a)
70   {
71     super(c, r, d, a);
72   }
73
74   /**
75    * Constructor which takes the format for this cell
76    *
77    * @param c the column
78    * @param r the row
79    * @param st the format
80    * @param d the date
81    */

82   public DateTime(int c, int r, Date JavaDoc d, CellFormat st)
83   {
84     super(c, r, d, st);
85   }
86
87   /**
88    * Constructor, which adjusts the specified date to take timezone
89    * considerations into account
90    *
91    * @param c the column
92    * @param r the row
93    * @param d the date
94    * @param st the cell format
95    * @param a the cummy overload
96    */

97   public DateTime(int c, int r, Date JavaDoc d, CellFormat st, GMTDate a)
98   {
99     super(c, r, d, st, a);
100   }
101
102   /**
103    * Constructor which takes the format for the cell and an indicator
104    * as to whether this cell is a full date time or purely just a time
105    * eg. if the spreadsheet is to contain the world record for 100m, then the
106    * value would be 9.83s, which would be indicated as just a time
107    *
108    * @param c the column
109    * @param r the row
110    * @param st the style
111    * @param tim flag indicating that this represents a time
112    * @param d the date
113    */

114   public DateTime(int c, int r, Date JavaDoc d, CellFormat st, boolean tim)
115   {
116     super(c, r, d, st, tim);
117   }
118
119   /**
120    * A constructor called by the worksheet when creating a writable version
121    * of a spreadsheet that has been read in
122    *
123    * @param dc the date to copy
124    */

125   public DateTime(DateCell dc)
126   {
127     super(dc);
128   }
129
130   /**
131    * Copy constructor used for deep copying
132    *
133    * @param col the column
134    * @param row the row
135    * @param dt the date to copy
136    */

137   protected DateTime(int col, int row, DateTime dt)
138   {
139     super(col, row, dt);
140   }
141
142
143   /**
144    * Sets the date for this cell
145    *
146    * @param d the date
147    */

148   public void setDate(Date JavaDoc d)
149   {
150     super.setDate(d);
151   }
152
153   /**
154    * Sets the date for this cell, performing the necessary timezone adjustments
155    *
156    * @param d the date
157    * @param a the dummy overload
158    */

159   public void setDate(Date JavaDoc d, GMTDate a)
160   {
161     super.setDate(d, a);
162   }
163
164   /**
165    * Implementation of the deep copy function
166    *
167    * @param col the column which the new cell will occupy
168    * @param row the row which the new cell will occupy
169    * @return a copy of this cell, which can then be added to the sheet
170    */

171   public WritableCell copyTo(int col, int row)
172   {
173     return new DateTime(col, row, this);
174   }
175 }
176
177
178
Popular Tags