| .. | .. |
|---|
| 5 | 5 | |
|---|
| 6 | 6 | public class TimeUnit |
|---|
| 7 | 7 | { |
|---|
| 8 | | - |
|---|
| 9 | 8 | public static final TimeUnit YEAR = new TimeUnit("Years", Calendar.YEAR, 365 * 24 * 60 * 60 * 1000L, "yyyy", "yyyy"); |
|---|
| 10 | 9 | public static final TimeUnit MONTH = new TimeUnit("Months", Calendar.MONTH, 30 * 24 * 60 * 60 * 1000L, "MMM", "MMM yyyy"); |
|---|
| 11 | 10 | public static final TimeUnit WEEK = new TimeUnit("Weeks", Calendar.WEEK_OF_YEAR, 7 * 24 * 60 * 60 * 1000L, "d", "MMM d yyyy"); |
|---|
| 12 | 11 | public static final TimeUnit DAY = new TimeUnit("Days", Calendar.DAY_OF_MONTH, 24 * 60 * 60 * 1000L, "d", "MMM d yyyy"); |
|---|
| 13 | 12 | public static final TimeUnit DAY_OF_WEEK = new TimeUnit("Days", Calendar.DAY_OF_WEEK, 24 * 60 * 60 * 1000L, "d", "MMM d yyyy"); |
|---|
| 14 | | - public static final TimeUnit HOUR = new TimeUnit("Hours", Calendar.HOUR_OF_DAY, 60 * 60 * 1000L, "kk:mm", "MMM d yyyy kk:mm"); |
|---|
| 15 | | - public static final TimeUnit MINUTE = new TimeUnit("Minutes", Calendar.MINUTE, 60 * 1000L, ":mm", "MMM d yyyy kk:mm"); |
|---|
| 16 | | - public static final TimeUnit SECOND = new TimeUnit("Seconds", Calendar.SECOND, 1000L, ":ss", "MMM d yyyy kk:mm:ss"); |
|---|
| 13 | + public static final TimeUnit HOUR = new TimeUnit("Hours", Calendar.HOUR_OF_DAY, 60 * 60 * 1000L, "HH:mm", "MMM d yyyy HH:mm"); |
|---|
| 14 | + public static final TimeUnit MINUTE = new TimeUnit("Minutes", Calendar.MINUTE, 60 * 1000L, ":mm", "MMM d yyyy HH:mm"); |
|---|
| 15 | + public static final TimeUnit SECOND = new TimeUnit("Seconds", Calendar.SECOND, 1000L, ":ss", "MMM d yyyy HH:mm:ss"); |
|---|
| 16 | + public static final TimeUnit REALTIME = new TimeUnit("Realtime", Calendar.MILLISECOND, 1L, ".SS", "HH:mm:ss.SS"); |
|---|
| 17 | + |
|---|
| 17 | 18 | public static final TimeUnit DECADE = multipleYears(10); |
|---|
| 18 | 19 | public static final TimeUnit CENTURY = multipleYears(100); |
|---|
| 19 | 20 | private static final double DAY_SIZE = 24 * 60 * 60 * 1000L; |
|---|
| .. | .. |
|---|
| 100 | 101 | } |
|---|
| 101 | 102 | private static final int[] calendarUnits = |
|---|
| 102 | 103 | { |
|---|
| 103 | | - Calendar.SECOND, Calendar.MINUTE, Calendar.HOUR_OF_DAY, Calendar.DAY_OF_MONTH, Calendar.MONTH, Calendar.YEAR |
|---|
| 104 | + Calendar.MILLISECOND, Calendar.SECOND, Calendar.MINUTE, Calendar.HOUR_OF_DAY, Calendar.DAY_OF_MONTH, Calendar.MONTH, Calendar.YEAR |
|---|
| 104 | 105 | }; |
|---|
| 105 | 106 | |
|---|
| 106 | 107 | public RoughTime round(long timestamp, boolean up) |
|---|
| .. | .. |
|---|
| 127 | 128 | } |
|---|
| 128 | 129 | if (i == calendarUnits.length - 1) |
|---|
| 129 | 130 | { |
|---|
| 130 | | - throw new IllegalArgumentException("Unsupported Calendar Unit: " + calendarCode); |
|---|
| 131 | + //throw new IllegalArgumentException("Unsupported Calendar Unit: " + calendarCode); |
|---|
| 131 | 132 | } |
|---|
| 132 | 133 | c.set(calendarUnits[i], c.getMinimum(calendarUnits[i])); |
|---|
| 133 | 134 | } |
|---|
| .. | .. |
|---|
| 237 | 238 | |
|---|
| 238 | 239 | public String format(Date date) |
|---|
| 239 | 240 | { |
|---|
| 240 | | - return format.format(date); |
|---|
| 241 | + return format.format(date); |
|---|
| 241 | 242 | } |
|---|
| 242 | 243 | |
|---|
| 243 | 244 | public String formatFull(Date date) |
|---|