本文整理了Java中java.time.ZonedDateTime.getDayOfWeek()
方法的一些代码示例,展示了ZonedDateTime.getDayOfWeek()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonedDateTime.getDayOfWeek()
方法的具体详情如下:
包路径:java.time.ZonedDateTime
类名称:ZonedDateTime
方法名:getDayOfWeek
[英]Gets the day-of-week field, which is an enum DayOfWeek.
This method returns the enum DayOfWeek for the day-of-week. This avoids confusion as to what int values mean. If you need access to the primitive int value then the enum provides the DayOfWeek#getValue().
Additional information can be obtained from the DayOfWeek. This includes textual names of the values.
[中]获取星期天字段,该字段是enum DayOfWeek。
此方法返回星期几的枚举DayOfWeek。这避免了对int值的含义的混淆。如果需要访问原语int值,则枚举提供DayOfWeek#getValue()。
更多信息可从DayOfWeek获得。这包括值的文本名称。
代码示例来源:origin: oracle/helidon
void validate(TimeValidator validator, ZonedDateTime now, Errors.Collector collector) {
// between times - it must fit at least one
boolean valid = false;
LocalTime nowTime = now.toLocalTime();
for (BetweenTime betweenTime : betweenTimes) {
if (betweenTime.isValid(nowTime)) {
valid = true;
}
}
if (!valid) {
collector.fatal(validator, nowTime.format(TIME_FORMATTER) + " is in neither of allowed times: " + betweenTimes);
}
DayOfWeek dayOfWeek = now.getDayOfWeek();
if (!daysOfWeek.contains(dayOfWeek)) {
collector.fatal(validator, dayOfWeek + " is not in allowed days: " + daysOfWeek);
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
public DayOfWeek getDayOfWeekEnum() {
return dt.getDayOfWeek();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Deprecated
public int getDayOfWeek() {
logDeprecated("getDayOfWeek()",
"The return type of [getDayOfWeek()] will change to an enum in 7.0. Use getDayOfWeekEnum().getValue().");
return dt.getDayOfWeek().getValue();
}
}
代码示例来源:origin: rakam-io/rakam
String month = dateTime.getMonth().getDisplayName(SHORT, US);
int day = dateTime.getDayOfMonth();
String weekDay = dateTime.getDayOfWeek().getDisplayName(SHORT, US);
DataSource dataSource = new ByteArrayDataSource(bytes, "image/png");
screenPart.setDataHandler(new DataHandler(dataSource));
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
public DayOfWeek getDayOfWeekEnum() {
return dt.getDayOfWeek();
}
代码示例来源:origin: apache/servicemix-bundles
public DayOfWeek getDayOfWeekEnum() {
return dt.getDayOfWeek();
}
代码示例来源:origin: com.daioware/dateUtilities
public static DayOfWeek getWeekDay() {
return getCurrentZonedDateTime().getDayOfWeek();
}
public static int getDay(){
代码示例来源:origin: Feature-Flip/flips
public static DayOfWeek getDayOfWeek(){
return getCurrentTime().getDayOfWeek();
}
}
代码示例来源:origin: com.guestful.module/guestful.module.jsr310-extensions
public static ZonedDateTime next(ZonedDateTime d, DayOfWeek day) {
while (d.getDayOfWeek() != day) {
d = d.plusDays(1);
}
return d;
}
代码示例来源:origin: stackoverflow.com
ZoneId zoneId = ZoneId.of("America/Los_Angeles");
Instant instant = Instant.now();
ZonedDateTime zDateTime = ZonedDateTime.ofInstant(instant, zoneId);
DayOfWeek day = zDateTime.getDayOfWeek();
System.out.println(day.getDisplayName(TextStyle.SHORT, Locale.US));
System.out.println(day.getDisplayName(TextStyle.NARROW, Locale.US));
代码示例来源:origin: stackoverflow.com
final Instant startVal = Instant.now();
final ZonedDateTime date = startVal.atZone(ZoneOffset.UTC); // or whatever
final int daysUntilFriday = (DayOfWeek.FRIDAY.getValue() - date.getDayOfWeek().getValue() + 7) % 7; // +7 to avoid a negative value
final ZonedDateTime startOfNextFriday = date.plusDays(daysUntilFriday).truncatedTo(ChronoUnit.DAYS);
final ZonedDateTime endOfNextFriday = ZonedDateTime.of(startOfNextFriday.toLocalDate(), LocalTime.MAX, startOfNextFriday.getZone());
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Deprecated
public int getDayOfWeek() {
logDeprecated("getDayOfWeek()",
"The return type of [getDayOfWeek()] will change to an enum in 7.0. Use getDayOfWeekEnum().getValue().");
return dt.getDayOfWeek().getValue();
}
}
代码示例来源:origin: apache/servicemix-bundles
@Deprecated
public int getDayOfWeek() {
logDeprecated("getDayOfWeek()",
"The return type of [getDayOfWeek()] will change to an enum in 7.0. Use getDayOfWeekEnum().getValue().");
return dt.getDayOfWeek().getValue();
}
}
代码示例来源:origin: co.cask.wrangler/wrangler-core
/**
* Extracts day of the week from the date.
*
* @param date to extract date of the week.
* @return day of the week.
*/
public static int DAY_OF_WEEK(ZonedDateTime date) {
validate(date, "DAY_OF_WEEK");
return date.getDayOfWeek().getValue();
}
代码示例来源:origin: stackoverflow.com
ZoneId zoneId = ZoneId.of( "America/Montreal" );
ZonedDateTime now = ZonedDateTime.now( zoneId );
int dayOfMonth = now.getDayOfMonth();
int dayOfWeek = now.getDayOfWeek().getValue();
int dayOfYear = now.getDayOfYear();
代码示例来源:origin: io.atlasmap/atlas-core
@AtlasFieldActionInfo(name = "DayOfWeek", sourceType = FieldType.ANY_DATE, targetType = FieldType.INTEGER, sourceCollectionType = CollectionType.NONE, targetCollectionType = CollectionType.NONE)
public static Integer dayOfWeek(Action action, ZonedDateTime input) {
return input == null ? null : input.getDayOfWeek().getValue();
}
代码示例来源:origin: AnalyticalGraphicsInc/czml-writer
/**
* Gets the day of the week represented by this instance.
* @return A {@code DayOfWeek} ({@link #getDayOfWeek get}) enumerated constant that indicates the day
of the week. This property value ranges from zero, indicating Sunday, to six,
indicating Saturday.
*/
@Nonnull
public final DayOfWeek getDayOfWeek() {
return DateTimeHelper.create(getYear(), getMonth(), getDay()).getDayOfWeek();
}
代码示例来源:origin: ExpediaDotCom/adaptive-alerting
/**
* Returns the largest week either before or equal to the given date, based on UTC time.
*
* @param date A date.
* @return Largest week before or equal to the given week.
*/
public static Instant truncatedToWeek(Instant date) {
notNull(date, "date can't be null");
final DayOfWeek dow = ZonedDateTime.ofInstant(date, ZoneOffset.UTC).getDayOfWeek();
return truncatedToDay(date).minus(Duration.ofDays(dow.getValue() % 7));
}
代码示例来源:origin: apache/james-project
@Test
void dayOfWeekShouldBeParsed() {
ZonedDateTime dateTime = ZonedDateTime.parse("Wed, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getDayOfWeek()).isEqualTo(DayOfWeek.WEDNESDAY);
}
代码示例来源:origin: org.apache.james/james-server-util-java8
@Test
public void dayOfWeekShouldBeParsed() {
ZonedDateTime dateTime = ZonedDateTime.parse("Wed, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getDayOfWeek()).isEqualTo(DayOfWeek.WEDNESDAY);
}
内容来源于网络,如有侵权,请联系作者删除!