|
@@ -5,7 +5,6 @@ |
5 |
5 |
|
|
6 |
6 |
|
import org.litesoft.core.simpletypes.temporal.nonpublic.*; |
7 |
7 |
|
import org.litesoft.core.typeutils.*; |
8 |
|
- |
import org.litesoft.core.typeutils.gregorian.*; |
9 |
8 |
|
import org.litesoft.deprecated.*; |
10 |
9 |
|
|
11 |
10 |
|
/** |
|
@@ -14,33 +13,32 @@ |
14 |
13 |
|
public class UtilDateAdaptor extends LL_UtilDateAdaptor implements TimestampWithResolutionAccessor, |
15 |
14 |
|
TimestampAccessorHMSM |
16 |
15 |
|
{ |
17 |
|
- |
private UtilDateAdaptor( long pUTC, TemporalResolution pTemporalResolution ) |
|
16 |
+ |
public UtilDateAdaptor( Date pDate, TemporalResolution pTemporalResolution ) |
18 |
17 |
|
{ |
19 |
|
- |
super( new Date( pUTC ), TemporalResolution.deNull( pTemporalResolution ).ordinal() ); |
|
18 |
+ |
super( pDate, TemporalResolution.deNull( pTemporalResolution ).ordinal() ); |
20 |
19 |
|
} |
21 |
20 |
|
|
22 |
|
- |
/** |
23 |
|
- |
* create with NOW |
24 |
|
- |
*/ |
25 |
|
- |
public UtilDateAdaptor() |
|
21 |
+ |
public UtilDateAdaptor( Date pDate ) |
26 |
22 |
|
{ |
27 |
|
- |
this( System.currentTimeMillis(), null ); |
|
23 |
+ |
this( pDate, null ); |
28 |
24 |
|
} |
29 |
25 |
|
|
30 |
|
- |
public UtilDateAdaptor( Date pDate ) |
|
26 |
+ |
public UtilDateAdaptor( long pUTC, TemporalResolution pTemporalResolution ) |
31 |
27 |
|
{ |
32 |
|
- |
this( pDate, null ); |
|
28 |
+ |
this( new Date( pUTC ), pTemporalResolution ); |
33 |
29 |
|
} |
34 |
30 |
|
|
35 |
|
- |
public UtilDateAdaptor( Date pDate, TemporalResolution pTemporalResolution ) |
|
31 |
+ |
/** |
|
32 |
+ |
* create with NOW |
|
33 |
+ |
*/ |
|
34 |
+ |
public UtilDateAdaptor() |
36 |
35 |
|
{ |
37 |
|
- |
super( pDate, TemporalResolution.deNull( pTemporalResolution ).ordinal() ); |
|
36 |
+ |
this( System.currentTimeMillis(), null ); |
38 |
37 |
|
} |
39 |
38 |
|
|
40 |
|
- |
private UtilDateAdaptor( int pOffsetMinutes, TemporalResolution pTemporalResolution, int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec, |
41 |
|
- |
int pMilliSec ) |
|
39 |
+ |
public UtilDateAdaptor force( TemporalResolution pResolution ) |
42 |
40 |
|
{ |
43 |
|
- |
super( pOffsetMinutes, pTemporalResolution.ordinal(), pYear, pMonth, pDay, pHour, pMin, pSec, pMilliSec ); |
|
41 |
+ |
return (getTemporalResolution() == pResolution) ? this : new UtilDateAdaptor( getUTClong(), pResolution ); |
44 |
42 |
|
} |
45 |
43 |
|
|
46 |
44 |
|
public static UtilDateAdaptor wall( int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec, int pMilliSec ) |
|
@@ -113,26 +111,6 @@ |
113 |
111 |
|
return new UtilDateAdaptor( UTC( pYear, 1, 1, 0, 0, 0, 0 ), TemporalResolution.ToYear ); |
114 |
112 |
|
} |
115 |
113 |
|
|
116 |
|
- |
public static UtilDateAdaptor offsetWallToMilliSec( int pOffsetMinutes, int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec, int pMilliSec ) |
117 |
|
- |
{ |
118 |
|
- |
return new UtilDateAdaptor( pOffsetMinutes, TemporalResolution.ToMilliSec, pYear, pMonth, pDay, pHour, pMin, pSec, pMilliSec ); |
119 |
|
- |
} |
120 |
|
- |
|
121 |
|
- |
public static UtilDateAdaptor offsetWallToSec( int pOffsetMinutes, int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec ) |
122 |
|
- |
{ |
123 |
|
- |
return new UtilDateAdaptor( pOffsetMinutes, TemporalResolution.ToSec, pYear, pMonth, pDay, pHour, pMin, pSec, 0 ); |
124 |
|
- |
} |
125 |
|
- |
|
126 |
|
- |
public static UtilDateAdaptor offsetWallToMin( int pOffsetMinutes, int pYear, int pMonth, int pDay, int pHour, int pMin ) |
127 |
|
- |
{ |
128 |
|
- |
return new UtilDateAdaptor( pOffsetMinutes, TemporalResolution.ToMin, pYear, pMonth, pDay, pHour, pMin, 0, 0 ); |
129 |
|
- |
} |
130 |
|
- |
|
131 |
|
- |
public static UtilDateAdaptor offsetWallToHour( int pOffsetMinutes, int pYear, int pMonth, int pDay, int pHour ) |
132 |
|
- |
{ |
133 |
|
- |
return new UtilDateAdaptor( pOffsetMinutes, TemporalResolution.ToHour, pYear, pMonth, pDay, pHour, 0, 0, 0 ); |
134 |
|
- |
} |
135 |
|
- |
|
136 |
114 |
|
public static UtilDateAdaptor fromUtilDateToString( String pDateToString ) |
137 |
115 |
|
{ |
138 |
116 |
|
return (pDateToString != null) ? new UtilDateAdaptor( UtilDateAdaptor.parseUtilDate( pDateToString ), null ) : null; |
|
@@ -202,53 +180,7 @@ |
202 |
180 |
|
|
203 |
181 |
|
public long getUTClong() |
204 |
182 |
|
{ |
205 |
|
- |
int zYear = mYear; |
206 |
|
- |
int zMonth = mMonth; |
207 |
|
- |
int zDay = mDay; |
208 |
|
- |
int zHour = mHour; |
209 |
|
- |
int zMin = mMin; |
210 |
|
- |
if ( mUTCtoWallOffsetMinutes != 0 ) // then Adjust the time to UTC |
211 |
|
- |
{ |
212 |
|
- |
zMin -= mUTCtoWallOffsetMinutes; // subtract the offset: to advance those to the west, and retard those to the east. |
213 |
|
- |
while ( zMin < 0 ) |
214 |
|
- |
{ |
215 |
|
- |
zMin += 60; |
216 |
|
- |
if ( --zHour < 0 ) |
217 |
|
- |
{ |
218 |
|
- |
zHour += 24; |
219 |
|
- |
if ( --zDay < 1 ) |
220 |
|
- |
{ |
221 |
|
- |
if ( --zMonth < 1 ) |
222 |
|
- |
{ |
223 |
|
- |
zMonth = 12; |
224 |
|
- |
zYear--; |
225 |
|
- |
} |
226 |
|
- |
zDay = Month.daysIn( zYear, zMonth ); |
227 |
|
- |
} |
228 |
|
- |
} |
229 |
|
- |
} |
230 |
|
- |
while ( 60 <= zMin ) |
231 |
|
- |
{ |
232 |
|
- |
zMin -= 60; |
233 |
|
- |
if ( 23 < ++zHour ) |
234 |
|
- |
{ |
235 |
|
- |
zHour -= 24; |
236 |
|
- |
if ( 28 < ++zDay ) |
237 |
|
- |
{ |
238 |
|
- |
if ( Month.daysIn( zYear, zMonth ) < zDay ) |
239 |
|
- |
{ |
240 |
|
- |
zDay = 1; |
241 |
|
- |
if ( 12 < ++zMonth ) |
242 |
|
- |
{ |
243 |
|
- |
zMonth = 1; |
244 |
|
- |
zYear++; |
245 |
|
- |
} |
246 |
|
- |
} |
247 |
|
- |
} |
248 |
|
- |
} |
249 |
|
- |
} |
250 |
|
- |
} |
251 |
|
- |
return UTC( zYear, zMonth, zDay, zHour, zMin, mSec, mMilliSec ); |
|
183 |
+ |
return mUTC; |
252 |
184 |
|
} |
253 |
185 |
|
|
254 |
186 |
|
public Date getWallDate() |