litesoft
@ 898
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
package org.litesoft.core.simpletypes.temporal; import org.litesoft.core.typeutils.*; /** * A Timestamp with resolution to the MilliSec ("Wall" relative) (with tracking for the Offset Minutes from Zulu). * <p/> * Note: This class supports Gregorian dates only. As such when working with * Java Util Date(s) (or it's descendants) the local (or "Wall") date & time is all that is considered! */ public class TimestampHMSM extends AbstractTimestampHMSM<TimestampHMSM, AbstractTimestampHMSM.Mutable> { private static final long serialVersionUID = 1L; @SuppressWarnings({"deprecation", "UnusedDeclaration"}) @Deprecated /** for Serialization */ protected TimestampHMSM() { this( 0, 0, 0, 0, 0, 0, 0, 0 ); } private TimestampHMSM( int pYear, int pMonth, int pDay, int pZuluOffsetMins, int pHour, int pMin, int pSec, int pMilliSec ) { super( null ); // TODO: pYear, pMonth, pDay, pZuluOffsetMins, pHour, pMin, pSec, pMilliSec ); } public TimestampHMSM( TimestampAccessorHMSM pAccessor ) { this( pAccessor.getYear(), pAccessor.getMonth(), pAccessor.getDay(), // pAccessor.getZuluOffsetMins(), // pAccessor.getHour(), pAccessor.getMin(), pAccessor.getSec(), pAccessor.getMilliSec() ); } @Override protected UtilDateAdaptor createWall() { return null; // TODO: XXX } public static TimestampHMSM fromWallTime( int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec, String pFraction ) { return fromWallTime( pYear, pMonth, pDay, pHour, pMin, pSec, fractionOf1000( pFraction ) ); } public static TimestampHMSM fromWallTime( int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec, int pMilliSec ) { return new TimestampHMSM( UtilDateAdaptor.wall( pYear, pMonth, pDay, pHour, pMin, pSec, pMilliSec ) ); } public static TimestampHMSM fromISO8601( int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec, String pFraction, boolean pZulu, Integer pUTC_offsetMinutes ) { return fromISO8601( pYear, pMonth, pDay, pHour, pMin, pSec, fractionOf1000( pFraction ), pZulu, pUTC_offsetMinutes ); } public static TimestampHMSM fromISO8601( int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec, int pMilliSec, boolean pZulu, Integer pUTC_offsetMinutes ) { int zZuluOffsetMins = Integers.deNull( pUTC_offsetMinutes ); Mutable zMutable = new Mutable( pYear, pMonth, pDay, // false, // pHour, pMin, pSec, pMilliSec ); if ( pZulu || (zZuluOffsetMins == 0) ) { // TODO: zMutable.fromZuluToWall(); } else // !Zulu && zZuluOffsetMins != 0 { // TODO: zMutable.fromOriginalWallToWall(); } return null; // TODO: new TimestampHMSM( zMutable ); } @Override public TemporalResolution getResolution() { return TemporalResolution.ToMilliSec; } @Override public String toString() { return toYMDHMSM(); } public static String toString( TimestampHMSM pTimestamp ) { return (pTimestamp != null) ? pTimestamp.toString() : null; } public static String toYMDHMSM( TimestampHMSM pTimestamp ) { return (pTimestamp != null) ? pTimestamp.toYMDHMSM() : null; } public String toYMDHMSM() { return formatSortableDisplayFormYMDHMSM( this, new StringBuilder() ).toString(); } public static TimestampHMSM fromYMDHMSM( String pToYMDHMSM ) throws IllegalArgumentException { String[] parts = parseSimple( pToYMDHMSM, "// ::." ); return (parts == null) ? null : // fromWallTime( parseYear( pToYMDHMSM, parts ), // parseMonth( pToYMDHMSM, parts ), // parseDay( pToYMDHMSM, parts ), // parseHour( pToYMDHMSM, parts ), // parseMin( pToYMDHMSM, parts ), // parseSec( pToYMDHMSM, parts ), // parseMilliSec( pToYMDHMSM, parts ) ); } public final String toSQLvalue() { Mutable zMutable = new Mutable( getYear(), getMonth(), getDay(), false, getHour(), getMin(), getSec(), getMilliSec() ); // TODO: zMutable.fromWallToZulu(); return null; // TODO: formatSQLvalueYMDH( zMutable, true, new StringBuilder() ).toString(); } public static TimestampHMSM fromSQLvalue( String pToSQLvalue ) { String[] parts = parseSimple( pToSQLvalue, "--TZ::." ); return (parts == null) ? null : // fromISO8601( parseYear( pToSQLvalue, parts ), // parseMonth( pToSQLvalue, parts ), // parseDay( pToSQLvalue, parts ), // parseHour( pToSQLvalue, parts ), // parseMin( pToSQLvalue, parts ), // parseSec( pToSQLvalue, parts ), // parseMilliSec( pToSQLvalue, parts ), // true, parseOffset( pToSQLvalue, parts ) ); } @Override public UtilDateAdaptor toUtilDateAdaptor() { return null; // TODO: UtilDateAdaptor.offsetWallToMilliSec( getZuluOffsetMins(), getYear(), getMonth(), getDay(), getHour(), getMin(), getSec(), getMilliSec() ); } // vvvvvvvvvvvvvvvvvv Non-common Public methods vvvvvvvvvvvvvvvvv public static TimestampHMSM now() { return new TimestampHMSM( new UtilDateAdaptor() ); } // vvvvvvvvvvvvvvvvvv Support methods vvvvvvvvvvvvvvvvv @Override protected TimestampHMSM createTypeFrom( Mutable pMutable ) { return null; // TODO: new TimestampHMSM( pMutable.getYear(), pMutable.getMonth(), pMutable.getDay(), // // pMutable.getZuluOffsetMins(), // // pMutable.getHour(), pMutable.getMin(), pMutable.getSec(), pMutable.getMilliSec() ); } @Override protected Mutable createMutable( int pYear, int pNewMonth ) { return new Mutable( pYear, pNewMonth, getDay(), true, getHour(), getMin(), getSec(), getMilliSec() ); } @Override protected Mutable createMutable( int pYear, int pMonth, int pNewDay ) { return new Mutable( pYear, pMonth, pNewDay, false, getHour(), getMin(), getSec(), getMilliSec() ); } @Override protected Mutable createMutable( int pYear, int pMonth, int pDay, int pNewHour ) { return new Mutable( pYear, pMonth, pDay, false, pNewHour, getMin(), getSec(), getMilliSec() ); } @Override protected Mutable createMutable( int pYear, int pMonth, int pDay, int pHour, int pNewMin ) { return new Mutable( pYear, pMonth, pDay, false, pHour, pNewMin, getSec(), getMilliSec() ); } @Override protected Mutable createMutable( int pYear, int pMonth, int pDay, int pHour, int pMin, int pNewSec ) { return new Mutable( pYear, pMonth, pDay, false, pHour, pMin, pNewSec, getMilliSec() ); } @Override protected Mutable createMutable( int pYear, int pMonth, int pDay, int pHour, int pMin, int pSec, int pNewMilliSec ) { return new Mutable( pYear, pMonth, pDay, false, pHour, pMin, pSec, pNewMilliSec ); } } |