KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portlet > forums > helper > Time


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Forums JBoss Portlet *
6  * *
7  * Distributable under GPL license. *
8  * See terms of license at gnu.org. *
9  * *
10  *****************************************/

11 package org.jboss.portlet.forums.helper;
12
13 import java.util.Date JavaDoc;
14
15 /**
16  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
17  * @version $Revision: 1.1.1.1 $
18  */

19 public class Time
20 {
21    /** DOCUMENT_ME */
22    public static final int SAME_DATE = 0x01;
23
24    /** DOCUMENT_ME */
25    public static final int LEFT_NULL = 0x02;
26
27    /** DOCUMENT_ME */
28    public static final int RIGHT_NULL = 0x04;
29
30    /** DOCUMENT_ME */
31    public static final int BOTH_NULL = 0x08;
32
33    /** DOCUMENT_ME */
34    public static final int LEFT_AFTER = 0x10;
35
36    /** DOCUMENT_ME */
37    public static final int RIGHT_AFTER = 0x20;
38
39    /**
40     * DOCUMENT_ME
41     *
42     * @param left DOCUMENT_ME
43     * @param right DOCUMENT_ME
44     *
45     * @return DOCUMENT_ME
46     */

47    public static int compare(Date JavaDoc left,
48                              Date JavaDoc right)
49    {
50       if (left == null)
51       {
52          return (right == null) ? BOTH_NULL : LEFT_NULL;
53       }
54
55       if (right == null)
56       {
57          return (left == null) ? BOTH_NULL : RIGHT_NULL;
58       }
59
60       if (left.equals(right))
61       {
62          return SAME_DATE;
63       }
64       else if (left.after(right))
65       {
66          return LEFT_AFTER;
67       }
68       else
69       {
70          return RIGHT_AFTER;
71       }
72    }
73 }
Popular Tags