Java Code Examples for java.util.Date#UTC
The following examples show how to use
java.util.Date#UTC .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Timestamp.java From ion-java with Apache License 2.0 | 6 votes |
/** * Returns a BigDecimal representing the Timestamp's point in time that is * the number of milliseconds (<em>including</em> any fractional milliseconds) * from the epoch. * <p> * This method will return the same result for all Timestamps representing * the same point in time, regardless of the local offset. * * @return * number of milliseconds (<em>including</em> any fractional * milliseconds) from the epoch (1970-01-01T00:00:00.000Z) */ @SuppressWarnings("deprecation") public BigDecimal getDecimalMillis() { switch (this._precision) { case YEAR: case MONTH: case DAY: case MINUTE: case SECOND: case FRACTION: long millis = Date.UTC(this._year - 1900, this._month - 1, this._day, this._hour, this._minute, this._second); BigDecimal dec = BigDecimal.valueOf(millis); if (_fraction != null) { dec = dec.add(this._fraction.movePointRight(3)); } return dec; } throw new IllegalArgumentException(); }
Example 2
Source File: Timestamp.java From ion-java with Apache License 2.0 | 5 votes |
/** * Returns a number representing the Timestamp's point in time that is * the number of milliseconds (<em>ignoring</em> any fractional milliseconds) * from the epoch. * <p> * This method will return the same result for all Timestamps representing * the same point in time, regardless of the local offset. * * @return * number of milliseconds (<em>ignoring</em> any fractional * milliseconds) from the epoch (1970-01-01T00:00:00.000Z) */ @SuppressWarnings("deprecation") public long getMillis() { // month is 0 based for Date long millis = Date.UTC(this._year - 1900, this._month - 1, this._day, this._hour, this._minute, this._second); if (this._fraction != null) { BigDecimal fracAsDecimal = this._fraction.movePointRight(3); int frac = isIntegralZero(fracAsDecimal) ? 0 : fracAsDecimal.intValue(); millis += frac; } return millis; }
Example 3
Source File: JsonFormatTest.java From domino-jackson with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") public static long getUTCTime(int year, int month, int day, int hour, int minute, int second, int milli) { return Date.UTC(year - 1900, month - 1, day, hour, minute, second) + milli; }
Example 4
Source File: AbstractTester.java From gwt-jackson with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") public static long getUTCTime( int year, int month, int day, int hour, int minute, int second, int milli ) { return Date.UTC( year - 1900, month - 1, day, hour, minute, second ) + milli; }