本文整理匯總了Java中org.joda.time.DateTimeUtils.getInstantMillis方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTimeUtils.getInstantMillis方法的具體用法?Java DateTimeUtils.getInstantMillis怎麽用?Java DateTimeUtils.getInstantMillis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.joda.time.DateTimeUtils
的用法示例。
在下文中一共展示了DateTimeUtils.getInstantMillis方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: BaseInterval
import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
/**
* Constructs an interval from a start and end instant.
*
* @param start start of this interval, null means now
* @param end end of this interval, null means now
* @throws IllegalArgumentException if the end is before the start
*/
protected BaseInterval(ReadableInstant start, ReadableInstant end) {
super();
if (start == null && end == null) {
iStartMillis = iEndMillis = DateTimeUtils.currentTimeMillis();
iChronology = ISOChronology.getInstance();
} else {
iChronology = DateTimeUtils.getInstantChronology(start);
iStartMillis = DateTimeUtils.getInstantMillis(start);
iEndMillis = DateTimeUtils.getInstantMillis(end);
checkInterval(iStartMillis, iEndMillis);
}
}
示例2: BasePeriod
import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
/**
* Creates a period from the given interval endpoints.
*
* @param startInstant interval start, null means now
* @param endInstant interval end, null means now
* @param type which set of fields this period supports, null means standard
* @throws IllegalArgumentException if period type is invalid
*/
protected BasePeriod(ReadableInstant startInstant, ReadableInstant endInstant, PeriodType type) {
super();
type = checkPeriodType(type);
if (startInstant == null && endInstant == null) {
iType = type;
iValues = new int[size()];
} else {
long startMillis = DateTimeUtils.getInstantMillis(startInstant);
long endMillis = DateTimeUtils.getInstantMillis(endInstant);
Chronology chrono = DateTimeUtils.getIntervalChronology(startInstant, endInstant);
iType = type;
iValues = chrono.get(this, startMillis, endMillis);
}
}
示例3: BaseDuration
import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
/**
* Creates a duration from the given interval endpoints.
*
* @param start interval start, null means now
* @param end interval end, null means now
* @throws ArithmeticException if the duration exceeds a 64 bit long
*/
protected BaseDuration(ReadableInstant start, ReadableInstant end) {
super();
if (start == end) {
iMillis = 0L;
} else {
long startMillis = DateTimeUtils.getInstantMillis(start);
long endMillis = DateTimeUtils.getInstantMillis(end);
iMillis = FieldUtils.safeAdd(endMillis, -startMillis);
}
}
示例4: toDurationFrom
import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
/**
* Gets the total millisecond duration of this period relative to a start instant.
* <p>
* This method adds the period to the specified instant in order to
* calculate the duration.
* <p>
* An instant must be supplied as the duration of a period varies.
* For example, a period of 1 month could vary between the equivalent of
* 28 and 31 days in milliseconds due to different length months.
* Similarly, a day can vary at Daylight Savings cutover, typically between
* 23 and 25 hours.
*
* @param startInstant the instant to add the period to, thus obtaining the duration
* @return the total length of the period as a duration relative to the start instant
* @throws ArithmeticException if the millis exceeds the capacity of the duration
*/
public Duration toDurationFrom(ReadableInstant startInstant) {
long startMillis = DateTimeUtils.getInstantMillis(startInstant);
Chronology chrono = DateTimeUtils.getInstantChronology(startInstant);
long endMillis = chrono.add(this, startMillis, 1);
return new Duration(startMillis, endMillis);
}
示例5: toDurationTo
import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
/**
* Gets the total millisecond duration of this period relative to an
* end instant.
* <p>
* This method subtracts the period from the specified instant in order
* to calculate the duration.
* <p>
* An instant must be supplied as the duration of a period varies.
* For example, a period of 1 month could vary between the equivalent of
* 28 and 31 days in milliseconds due to different length months.
* Similarly, a day can vary at Daylight Savings cutover, typically between
* 23 and 25 hours.
*
* @param endInstant the instant to subtract the period from, thus obtaining the duration
* @return the total length of the period as a duration relative to the end instant
* @throws ArithmeticException if the millis exceeds the capacity of the duration
*/
public Duration toDurationTo(ReadableInstant endInstant) {
long endMillis = DateTimeUtils.getInstantMillis(endInstant);
Chronology chrono = DateTimeUtils.getInstantChronology(endInstant);
long startMillis = chrono.add(this, endMillis, -1);
return new Duration(startMillis, endMillis);
}
示例6: toDateTime
import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
/**
* Resolves this partial against another complete instant to create a new
* full instant. The combination is performed using the chronology of the
* specified instant.
* <p>
* For example, if this partial represents a time, then the result of this
* method will be the datetime from the specified base instant plus the
* time from this partial.
*
* @param baseInstant the instant that provides the missing fields, null means now
* @return the combined datetime
*/
public DateTime toDateTime(ReadableInstant baseInstant) {
Chronology chrono = DateTimeUtils.getInstantChronology(baseInstant);
long instantMillis = DateTimeUtils.getInstantMillis(baseInstant);
long resolved = chrono.set(this, instantMillis);
return new DateTime(resolved, chrono);
}
示例7: isAfter
import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
/**
* Is this instant after the instant passed in
* comparing solely by millisecond.
*
* @param instant an instant to check against, null means now
* @return true if the instant is after the instant passed in
*/
public boolean isAfter(ReadableInstant instant) {
long instantMillis = DateTimeUtils.getInstantMillis(instant);
return isAfter(instantMillis);
}
示例8: isBefore
import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
/**
* Is this instant before the instant passed in
* comparing solely by millisecond.
*
* @param instant an instant to check against, null means now
* @return true if the instant is before the instant passed in
*/
public boolean isBefore(ReadableInstant instant) {
long instantMillis = DateTimeUtils.getInstantMillis(instant);
return isBefore(instantMillis);
}
示例9: isEqual
import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
/**
* Is this instant equal to the instant passed in
* comparing solely by millisecond.
*
* @param instant an instant to check against, null means now
* @return true if the instant is equal to the instant passed in
*/
public boolean isEqual(ReadableInstant instant) {
long instantMillis = DateTimeUtils.getInstantMillis(instant);
return isEqual(instantMillis);
}
示例10: printTo
import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
/**
* Prints a ReadableInstant, using the chronology supplied by the instant.
*
* @param buf the destination to format to, not null
* @param instant instant to format, null means now
*/
public void printTo(StringBuffer buf, ReadableInstant instant) {
long millis = DateTimeUtils.getInstantMillis(instant);
Chronology chrono = DateTimeUtils.getInstantChronology(instant);
printTo(buf, millis, chrono);
}