KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hwpf > usermodel > DateAndTime


1 /* ====================================================================
2    Copyright 2002-2004 Apache Software Foundation
3
4    Licensed under the Apache License, Version 2.0 (the "License");
5    you may not use this file except in compliance with the License.
6    You may obtain a copy of the License at
7
8        http://www.apache.org/licenses/LICENSE-2.0
9
10    Unless required by applicable law or agreed to in writing, software
11    distributed under the License is distributed on an "AS IS" BASIS,
12    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    See the License for the specific language governing permissions and
14    limitations under the License.
15 ==================================================================== */

16
17
18
19 package org.apache.poi.hwpf.usermodel;
20
21 import org.apache.poi.util.BitField;
22 import org.apache.poi.util.LittleEndian;
23
24 /**
25  * This class is used to represent a date and time in a Word document.
26  *
27  * @author Ryan Ackley
28  */

29 public class DateAndTime
30   implements Cloneable JavaDoc
31 {
32   public static final int SIZE = 4;
33   private short _info;
34     private static final BitField _minutes = new BitField(0x3f);
35     private static final BitField _hours = new BitField(0x7c0);
36     private static final BitField _dom = new BitField(0xf800);
37   private short _info2;
38     private static final BitField _months = new BitField(0xf);
39     private static final BitField _years = new BitField(0x1ff0);
40     private static final BitField _weekday = new BitField(0xe000);
41
42   public DateAndTime()
43   {
44   }
45
46   public DateAndTime(byte[] buf, int offset)
47   {
48     _info = LittleEndian.getShort(buf, offset);
49     _info2 = LittleEndian.getShort(buf, offset + LittleEndian.SHORT_SIZE);
50   }
51
52   public void serialize(byte[] buf, int offset)
53   {
54     LittleEndian.putShort(buf, offset, _info);
55     LittleEndian.putShort(buf, offset + LittleEndian.SHORT_SIZE, _info2);
56   }
57
58   public boolean equals(Object JavaDoc o)
59   {
60     DateAndTime dttm = (DateAndTime)o;
61     return _info == dttm._info && _info2 == dttm._info2;
62   }
63
64   public Object JavaDoc clone()
65     throws CloneNotSupportedException JavaDoc
66   {
67     return super.clone();
68   }
69 }
70
Popular Tags