当前位置: 首页>>代码示例>>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;未经允许,请勿转载。