1 11 package org.jboss.portlet.forums.helper; 12 13 import java.util.Date ; 14 15 19 public class Time 20 { 21 22 public static final int SAME_DATE = 0x01; 23 24 25 public static final int LEFT_NULL = 0x02; 26 27 28 public static final int RIGHT_NULL = 0x04; 29 30 31 public static final int BOTH_NULL = 0x08; 32 33 34 public static final int LEFT_AFTER = 0x10; 35 36 37 public static final int RIGHT_AFTER = 0x20; 38 39 47 public static int compare(Date left, 48 Date 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 |