本文整理匯總了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);
}
示例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"))
);
}
示例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);
}
}
示例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;
}
示例5: test_factory_int_valueTooLow
import java.time.DayOfWeek; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_valueTooLow() {
DayOfWeek.of(0);
}
示例6: test_factory_int_valueTooHigh
import java.time.DayOfWeek; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void test_factory_int_valueTooHigh() {
DayOfWeek.of(8);
}
示例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);
}