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


Java DayOfWeek.of方法代碼示例

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


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

示例1: readExternal

import java.time.DayOfWeek; //導入方法依賴的package包/類
/**
 * Reads the state from the stream.
 *
 * @param in  the input stream, not null
 * @return the created object, not null
 * @throws IOException if an error occurs
 */
static ZoneOffsetTransitionRule readExternal(DataInput in) throws IOException {
    int data = in.readInt();
    Month month = Month.of(data >>> 28);
    int dom = ((data & (63 << 22)) >>> 22) - 32;
    int dowByte = (data & (7 << 19)) >>> 19;
    DayOfWeek dow = dowByte == 0 ? null : DayOfWeek.of(dowByte);
    int timeByte = (data & (31 << 14)) >>> 14;
    TimeDefinition defn = TimeDefinition.values()[(data & (3 << 12)) >>> 12];
    int stdByte = (data & (255 << 4)) >>> 4;
    int beforeByte = (data & (3 << 2)) >>> 2;
    int afterByte = (data & 3);
    LocalTime time = (timeByte == 31 ? LocalTime.ofSecondOfDay(in.readInt()) : LocalTime.of(timeByte % 24, 0));
    ZoneOffset std = (stdByte == 255 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds((stdByte - 128) * 900));
    ZoneOffset before = (beforeByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + beforeByte * 1800));
    ZoneOffset after = (afterByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + afterByte * 1800));
    return ZoneOffsetTransitionRule.of(month, dom, dow, time, timeByte == 24, defn, std, before, after);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:ZoneOffsetTransitionRule.java

示例2: from

import java.time.DayOfWeek; //導入方法依賴的package包/類
static Hours from(JSONObject hours) {
    return new Hours(
        DayOfWeek.of(hours.getInt("day") + 1),
        createTimeFrom(hours.getString("start")),
        createTimeFrom(hours.getString("end"))
    );
}
 
開發者ID:MontealegreLuis,項目名稱:yelpv3-java-client,代碼行數:8,代碼來源:BusinessParser.java

示例3: test_factory_int_singleton

import java.time.DayOfWeek; //導入方法依賴的package包/類
@Test
public void test_factory_int_singleton() {
    for (int i = 1; i <= 7; i++) {
        DayOfWeek test = DayOfWeek.of(i);
        assertEquals(test.getValue(), i);
        assertSame(DayOfWeek.of(i), test);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:9,代碼來源:TCKDayOfWeek.java

示例4: returnDayOfWeek

import java.time.DayOfWeek; //導入方法依賴的package包/類
/**
 * Returns the day of week that relates to benefits for the given Nino
 *
 * @param inputNino data number input to use
 * @return DayOfWeek relating to benefits for the given input
 * @throws InvalidNinoException if inputNino is invalid
 */
public static DayOfWeek returnDayOfWeek(String inputNino) throws InvalidNinoException {
    String reformattedInput = reformatInput(inputNino);
    DayOfWeek thisDay; // never returned
    if ((null != reformattedInput) && (validateNINO(reformattedInput))) {
        //0-19 = Monday, 20-39 = Tuesday etc.
        thisDay = DayOfWeek.of((parseInt(reformattedInput.substring(6, 8)) / 20) + 1);
    } else {
        throw new InvalidNinoException(NINO_ERROR_MESSAGE);
    }
    return thisDay;
}
 
開發者ID:dwpdigitaltech,項目名稱:nino-format-validation,代碼行數:19,代碼來源:NinoValidator.java

示例5: test_factory_int_valueTooLow

import java.time.DayOfWeek; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_valueTooLow() {
    DayOfWeek.of(0);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:TCKDayOfWeek.java

示例6: test_factory_int_valueTooHigh

import java.time.DayOfWeek; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_valueTooHigh() {
    DayOfWeek.of(8);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:TCKDayOfWeek.java

示例7: toISOfromCalendarDOW

import java.time.DayOfWeek; //導入方法依賴的package包/類
/**
 * Return the ISO Day of Week from a java.util.Calendr DAY_OF_WEEK.
 * @param the java.util.Calendar day of week (1=Sunday, 7=Saturday)
 * @return the ISO DayOfWeek
 */
private DayOfWeek toISOfromCalendarDOW(int i) {
    return DayOfWeek.of(Math.floorMod(i - 2, 7) + 1);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:9,代碼來源:TestIsoChronoImpl.java


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