|
@@ -2,15 +2,19 @@ |
2 |
2 |
|
|
3 |
3 |
|
import java.util.*; |
4 |
4 |
|
|
5 |
|
- |
public abstract class LL_UtilDateAdaptor |
|
5 |
+ |
/** |
|
6 |
+ |
* @noinspection deprecation, UnusedDeclaration |
|
7 |
+ |
*/ |
|
8 |
+ |
public class LL_UtilDateAdaptor |
6 |
9 |
|
{ |
|
10 |
+ |
protected final int mUTCtoWallOffsetMinutes; // 0 = UTC, -600 = HT (Hawaii Time or more formally: HST = Alaska-Hawaii Standard Time) |
7 |
11 |
|
protected final int mTimeFields; // 0 = None, 1 = Hour, 2 = Hour + Min, 3 = Hour-Sec, 4 = Hour-MilliSec |
8 |
|
- |
private final int mYear, mMonth, mDay, mHour, mMin, mSec, mMilliSec; |
|
12 |
+ |
protected final int mYear, mMonth, mDay, mHour, mMin, mSec, mMilliSec; |
9 |
13 |
|
|
10 |
|
- |
protected LL_UtilDateAdaptor( int pTimeFields, // |
11 |
|
- |
int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec, |
12 |
|
- |
int pMilliSec ) |
|
14 |
+ |
protected LL_UtilDateAdaptor( int pUTCtoWallOffsetMinutes, int pTimeFields, // |
|
15 |
+ |
int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec, int pMilliSec ) |
13 |
16 |
|
{ |
|
17 |
+ |
mUTCtoWallOffsetMinutes = pUTCtoWallOffsetMinutes; |
14 |
18 |
|
mTimeFields = pTimeFields; |
15 |
19 |
|
mYear = pYear; |
16 |
20 |
|
mMonth = (pMonth != 0) ? pMonth : 1; |
|
@@ -21,14 +25,9 @@ |
21 |
25 |
|
mMilliSec = pMilliSec; |
22 |
26 |
|
} |
23 |
27 |
|
|
24 |
|
- |
protected LL_UtilDateAdaptor( String pDate, int pTimeFields ) |
25 |
|
- |
{ |
26 |
|
- |
//noinspection deprecation |
27 |
|
- |
this( new Date( pDate ), pTimeFields ); |
28 |
|
- |
} |
29 |
|
- |
|
30 |
|
- |
protected LL_UtilDateAdaptor( Date pDate, int pTimeFields ) |
|
28 |
+ |
protected LL_UtilDateAdaptor( Date pWallDate, int pTimeFields ) |
31 |
29 |
|
{ |
|
30 |
+ |
mUTCtoWallOffsetMinutes = pWallDate.getTimezoneOffset(); |
32 |
31 |
|
int dHour = 0; |
33 |
32 |
|
int dMin = 0; |
34 |
33 |
|
int dSec = 0; |
|
@@ -36,93 +35,43 @@ |
36 |
35 |
|
switch ( mTimeFields = pTimeFields ) |
37 |
36 |
|
{ |
38 |
37 |
|
case 4: |
39 |
|
- |
long zMillisSinceEpoch = pDate.getTime(); |
|
38 |
+ |
long zMillisSinceEpoch = pWallDate.getTime(); |
40 |
39 |
|
int zRawMilliSec = (int) (zMillisSinceEpoch % 1000L); |
41 |
40 |
|
dMilliSec = (zRawMilliSec >= 0) ? zRawMilliSec : (1000 + zRawMilliSec); |
42 |
41 |
|
// Fall Thru |
43 |
42 |
|
case 3: |
44 |
|
- |
//noinspection deprecation |
45 |
|
- |
dSec = pDate.getSeconds(); |
|
43 |
+ |
dSec = pWallDate.getSeconds(); |
46 |
44 |
|
// Fall Thru |
47 |
45 |
|
case 2: |
48 |
|
- |
//noinspection deprecation |
49 |
|
- |
dMin = pDate.getMinutes(); |
|
46 |
+ |
dMin = pWallDate.getMinutes(); |
50 |
47 |
|
// Fall Thru |
51 |
48 |
|
case 1: |
52 |
|
- |
//noinspection deprecation |
53 |
|
- |
dHour = pDate.getHours(); |
|
49 |
+ |
dHour = pWallDate.getHours(); |
54 |
50 |
|
// Fall Thru |
55 |
51 |
|
default: |
56 |
52 |
|
break; |
57 |
53 |
|
} |
58 |
|
- |
//noinspection deprecation |
59 |
|
- |
mDay = pDate.getDate(); |
60 |
|
- |
//noinspection deprecation |
61 |
|
- |
mMonth = pDate.getMonth() + 1; |
62 |
|
- |
//noinspection deprecation |
63 |
|
- |
mYear = pDate.getYear() + 1900; |
|
54 |
+ |
mDay = pWallDate.getDate(); |
|
55 |
+ |
mMonth = pWallDate.getMonth() + 1; |
|
56 |
+ |
mYear = pWallDate.getYear() + 1900; |
64 |
57 |
|
mHour = dHour; |
65 |
58 |
|
mMin = dMin; |
66 |
59 |
|
mSec = dSec; |
67 |
60 |
|
mMilliSec = dMilliSec; |
68 |
61 |
|
} |
69 |
62 |
|
|
70 |
|
- |
public Date getDate() |
71 |
|
- |
{ |
72 |
|
- |
//noinspection deprecation |
73 |
|
- |
Date date = new Date( mYear - 1900, // |
74 |
|
- |
mMonth - 1, // |
75 |
|
- |
mDay, // |
76 |
|
- |
mHour, // |
77 |
|
- |
mMin, // |
78 |
|
- |
mSec ); |
79 |
|
- |
if ( (mTimeFields == 4) && (mMilliSec != 0) ) |
80 |
|
- |
{ |
81 |
|
- |
long zMillisSinceEpoch = date.getTime(); |
82 |
|
- |
long zAdjusted = zMillisSinceEpoch + mMilliSec; |
83 |
|
- |
date = new Date( zAdjusted ); |
84 |
|
- |
} |
85 |
|
- |
return date; |
86 |
|
- |
} |
87 |
|
- |
|
88 |
|
- |
public int getYear() |
89 |
|
- |
{ |
90 |
|
- |
return mYear; |
91 |
|
- |
} |
92 |
|
- |
|
93 |
|
- |
public int getMonth() |
94 |
|
- |
{ |
95 |
|
- |
return mMonth; |
96 |
|
- |
} |
97 |
|
- |
|
98 |
|
- |
public int getDay() |
99 |
|
- |
{ |
100 |
|
- |
return mDay; |
101 |
|
- |
} |
102 |
|
- |
|
103 |
|
- |
public int getHour() |
104 |
|
- |
{ |
105 |
|
- |
return mHour; |
106 |
|
- |
} |
107 |
|
- |
|
108 |
|
- |
public int getMin() |
109 |
|
- |
{ |
110 |
|
- |
return mMin; |
111 |
|
- |
} |
112 |
|
- |
|
113 |
|
- |
public int getSec() |
|
63 |
+ |
public static int dayOfWeek( Date pWallDate ) |
114 |
64 |
|
{ |
115 |
|
- |
return mSec; |
|
65 |
+ |
return pWallDate.getDay(); |
116 |
66 |
|
} |
117 |
67 |
|
|
118 |
|
- |
public int getMilliSec() |
|
68 |
+ |
public static long parseUtilDate( String pUtilDateToString ) |
119 |
69 |
|
{ |
120 |
|
- |
return mMilliSec; |
|
70 |
+ |
return Date.parse( pUtilDateToString ); |
121 |
71 |
|
} |
122 |
72 |
|
|
123 |
|
- |
public int getDayOfWeek() |
|
73 |
+ |
public static long UTC( int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec, int pMilliSec ) |
124 |
74 |
|
{ |
125 |
|
- |
//noinspection deprecation |
126 |
|
- |
return getDate().getDay(); |
|
75 |
+ |
return Date.UTC( pYear - 1900, pMonth - 1, pDay, pHour, pMin, pSec ) + pMilliSec; |
127 |
76 |
|
} |
128 |
77 |
|
} |