Example usage for java.time ZonedDateTime getDayOfWeek

List of usage examples for java.time ZonedDateTime getDayOfWeek

Introduction

In this page you can find the example usage for java.time ZonedDateTime getDayOfWeek.

Prototype

public DayOfWeek getDayOfWeek() 

Source Link

Document

Gets the day-of-week field, which is an enum DayOfWeek .

Usage

From source file:Main.java

public static void main(String[] args) {
    ZonedDateTime dateTime = ZonedDateTime.now();

    System.out.println(dateTime.getDayOfWeek());
}

From source file:nu.yona.server.analysis.service.ActivityServiceTest.java

private ZonedDateTime getWeekStartTime(ZonedDateTime dateTime) {
    ZonedDateTime dateAtStartOfDay = getDayStartTime(dateTime);
    switch (dateAtStartOfDay.getDayOfWeek()) {
    case SUNDAY://from  w w  w.  j  av  a 2 s  .c o  m
        return dateAtStartOfDay;
    default:
        return dateAtStartOfDay.minusDays(dateAtStartOfDay.getDayOfWeek().getValue());
    }
}

From source file:onl.area51.httpd.action.Request.java

default Request addHeader(String n, ZonedDateTime zdt) {
    return addHeader(n,
            String.format("%3s, %02d %3s %d %02d:%02d:%02d GMT",
                    zdt.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.ENGLISH), zdt.getDayOfMonth(),
                    zdt.getMonth().getDisplayName(TextStyle.SHORT, Locale.ENGLISH), zdt.getYear(),
                    zdt.getHour(), zdt.getMinute(), zdt.getSecond()));
}

From source file:io.stallion.jobs.Schedule.java

/**
 * Runs the given days of the week, every other week.
 *
 * @param startingAt/*from w  ww  . jav  a 2 s  .  c  o  m*/
 * @param days
 * @return
 */
public Schedule daysBiweekly(Long startingAt, DayOfWeek... days) {
    this._days.verifyAndUpdateUnset();
    this._days.setIntervalType(Days.IntervalType.BIWEEKLY_DAY_OF_WEEK);
    for (DayOfWeek day : days) {
        this._days.add(day.getValue());
    }
    ZonedDateTime startingWeek = ZonedDateTime.ofInstant(Instant.ofEpochMilli(startingAt), ZoneId.of("UTC"));
    // Get the Monday 12PM of that week
    startingWeek = startingWeek.minusDays(startingWeek.getDayOfWeek().getValue() - 1).withSecond(0).withHour(12)
            .withMinute(0).withNano(0);
    this._days.setStartingDate(startingWeek);
    return this;
}