Revision 477,
1.3 KB
checked in by wojtekp, 13 years ago
(diff) |
|
-
Property svn:mime-type set to
text/plain
|
Line | |
---|
1 | package org.joda.time; |
---|
2 | |
---|
3 | import java.lang.reflect.Field; |
---|
4 | import java.util.Calendar; |
---|
5 | |
---|
6 | import org.apache.commons.logging.Log; |
---|
7 | import org.apache.commons.logging.LogFactory; |
---|
8 | import org.joda.time.DateTimeUtils; |
---|
9 | |
---|
10 | /** |
---|
11 | * |
---|
12 | * @author Marcin Krystek |
---|
13 | * |
---|
14 | */ |
---|
15 | |
---|
16 | public class DateTimeUtilsExt extends DateTimeUtils { |
---|
17 | |
---|
18 | private static Log log = LogFactory.getLog(DateTimeUtilsExt.class); |
---|
19 | private static Calendar offsetTime; |
---|
20 | |
---|
21 | public static void initVirtualTimeAccess(Calendar startTime){ |
---|
22 | offsetTime = startTime; |
---|
23 | try { |
---|
24 | Field privateStringField = DateTimeUtils.class. |
---|
25 | getDeclaredField("cMillisProvider"); |
---|
26 | privateStringField.setAccessible(true); |
---|
27 | privateStringField.set(null, new VCMilisProvider(startTime)); |
---|
28 | privateStringField.setAccessible(false); |
---|
29 | |
---|
30 | log.info("org.joda.time PACKAGE IS USING SIMJAVA VIRTUAL CLOCK " + |
---|
31 | "TO DETERMINE CURRENT TIME."); |
---|
32 | |
---|
33 | } catch (SecurityException e) { |
---|
34 | e.printStackTrace(); |
---|
35 | } catch (NoSuchFieldException e) { |
---|
36 | e.printStackTrace(); |
---|
37 | } catch (IllegalArgumentException e) { |
---|
38 | e.printStackTrace(); |
---|
39 | } catch (IllegalAccessException e) { |
---|
40 | e.printStackTrace(); |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | public static DateTime getDateTimeAt(double vtime){ |
---|
45 | DateTime dt = new DateTime(offsetTime.getTimeInMillis()); |
---|
46 | return dt.plusSeconds((int) vtime); |
---|
47 | } |
---|
48 | |
---|
49 | public static Calendar getOffsetTime(){ |
---|
50 | return offsetTime; |
---|
51 | } |
---|
52 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.