當前位置: 首頁>>代碼示例>>Java>>正文


Java DateTimeConstants.MILLIS_PER_WEEK屬性代碼示例

本文整理匯總了Java中org.joda.time.DateTimeConstants.MILLIS_PER_WEEK屬性的典型用法代碼示例。如果您正苦於以下問題:Java DateTimeConstants.MILLIS_PER_WEEK屬性的具體用法?Java DateTimeConstants.MILLIS_PER_WEEK怎麽用?Java DateTimeConstants.MILLIS_PER_WEEK使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.joda.time.DateTimeConstants的用法示例。


在下文中一共展示了DateTimeConstants.MILLIS_PER_WEEK屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDifferenceAsLong

public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant) {
    if (minuendInstant < subtrahendInstant) {
        return -getDifference(subtrahendInstant, minuendInstant);
    }

    int minuendWeekyear = get(minuendInstant);
    int subtrahendWeekyear = get(subtrahendInstant);

    long minuendRem = remainder(minuendInstant);
    long subtrahendRem = remainder(subtrahendInstant);

    // Balance leap weekyear differences on remainders.
    if (subtrahendRem >= WEEK_53 && iChronology.getWeeksInYear(minuendWeekyear) <= 52) {
        subtrahendRem -= DateTimeConstants.MILLIS_PER_WEEK;
    }

    int difference = minuendWeekyear - subtrahendWeekyear;
    if (minuendRem < subtrahendRem) {
        difference--;
    }
    return difference;
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:22,代碼來源:BasicWeekyearDateTimeField.java

示例2: roundFloor

public long roundFloor(long instant) {
    // Note: This works fine, but it ideally shouldn't invoke other
    // fields from within a field.
    instant = iChronology.weekOfWeekyear().roundFloor(instant);
    int wow = iChronology.getWeekOfWeekyear(instant);
    if (wow > 1) {
        instant -= ((long) DateTimeConstants.MILLIS_PER_WEEK) * (wow - 1);
    }
    return instant;
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:10,代碼來源:BasicWeekyearDateTimeField.java

示例3: getWeekOfWeekyear

/**
 * @param instant millis from 1970-01-01T00:00:00Z
 * @param year precalculated year of millis
 */
int getWeekOfWeekyear(long instant, int year) {
    long firstWeekMillis1 = getFirstWeekOfYearMillis(year);
    if (instant < firstWeekMillis1) {
        return getWeeksInYear(year - 1);
    }
    long firstWeekMillis2 = getFirstWeekOfYearMillis(year + 1);
    if (instant >= firstWeekMillis2) {
        return 1;
    }
    return (int) ((instant - firstWeekMillis1) / DateTimeConstants.MILLIS_PER_WEEK) + 1;
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:15,代碼來源:BasicChronology.java

示例4: getWeeksInYear

/**
 * Get the number of weeks in the year.
 *
 * @param year  the year to use
 * @return number of weeks in the year
 */
int getWeeksInYear(int year) {
    long firstWeekMillis1 = getFirstWeekOfYearMillis(year);
    long firstWeekMillis2 = getFirstWeekOfYearMillis(year + 1);
    return (int) ((firstWeekMillis2 - firstWeekMillis1) / DateTimeConstants.MILLIS_PER_WEEK);
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:11,代碼來源:BasicChronology.java


注:本文中的org.joda.time.DateTimeConstants.MILLIS_PER_WEEK屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。