org.joda.time.LocalDate.getDayOfWeek()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(197)

本文整理了Java中org.joda.time.LocalDate.getDayOfWeek()方法的一些代码示例,展示了LocalDate.getDayOfWeek()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDate.getDayOfWeek()方法的具体详情如下:
包路径:org.joda.time.LocalDate
类名称:LocalDate
方法名:getDayOfWeek

LocalDate.getDayOfWeek介绍

[英]Get the day of week field value.

The values for the day of week are defined in org.joda.time.DateTimeConstants.
[中]获取“星期几”字段值。
星期几的值在组织中定义。乔达。时间DateTimeConstants。

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

DayOfWeek dayOfWeek = DayOfWeek.of(request.date.getDayOfWeek());

代码示例来源:origin: com.github.fosin/cdp-utils

/**
 * getWeekDay
 *
 * @return a int.
 */
public int getWeekDay(){
  LocalDate dt = new LocalDate();
  return dt.getDayOfWeek();
}

代码示例来源:origin: qcadoo/mes

/**
 * Check if this shift will be working at given local date. This method is NOT aware of timetable exceptions
 * 
 * @param localDate
 * @return true if this shift will be working at given local date.
 */
public boolean worksAt(final LocalDate localDate) {
  return worksAt(localDate.getDayOfWeek());
}

代码示例来源:origin: net.objectlab.kit/datecalc-joda

public static int jodaToCalendarDayConstant(final LocalDate date) {
  return jodaToCalendarDayConstant(date.getDayOfWeek());
}

代码示例来源:origin: qcadoo/mes

/**
 * Returns a list with shift work time ranges for whole given day (of the week, to be precise). This method IS NOT AWARE of
 * timetable exceptions, it just check if shift works at given day of week and returns working hours.
 * 
 * @param localDate
 *            date to check
 * @return shift's work time ranges for given date
 * @since 1.4
 */
public List<TimeRange> findWorkTimeAt(final LocalDate localDate) {
  return Fold.fold(workingHoursPerDay.get(localDate.getDayOfWeek()), Lists.<TimeRange> newArrayList(),
      new BiFunction<List<TimeRange>, WorkingHours, List<TimeRange>>() {
        @Override
        public List<TimeRange> apply(final List<TimeRange> acc, final WorkingHours wh) {
          acc.addAll(wh.getTimeRanges());
          return acc;
        }
      });
}

代码示例来源:origin: yannecer/NCalendar

@Override
public void onCalendarDateChanged(NDate date,boolean isClick) {
  tv_year.setText(date.localDate.getYear() + "年");
  tv_month.setText(date.localDate.getMonthOfYear() + "月");
  tv_week.setText(weeks[date.localDate.getDayOfWeek() - 1]);
  tv_lunar.setText("农历" + date.lunar.lunarYearStr + "年 ");
  tv_lunar_tg.setText(date.lunar.lunarMonthStr + date.lunar.lunarDayStr + (TextUtils.isEmpty(date.lunarHoliday) ? "" : (" | " + date.lunarHoliday)) + (TextUtils.isEmpty(date.solarHoliday) ? "" : (" | " + date.solarHoliday)));
}

代码示例来源:origin: Appendium/objectlabkit

public static int jodaToCalendarDayConstant(final LocalDate date) {
  return jodaToCalendarDayConstant(date.getDayOfWeek());
}

代码示例来源:origin: qcadoo/mes

public Optional<Shift> findShiftWorkingAt(final LocalTime time) {
  final int dayOfWeek = orderStartDate.plusDays(realizationDayNumber - 1).getDayOfWeek();
  return FluentIterable.from(workingShifts).firstMatch(new Predicate<Shift>() {
    @Override
    public boolean apply(final Shift shift) {
      return shift.worksAt(dayOfWeek, time);
    }
  });
}

代码示例来源:origin: com.synaptix/SynaptixWidget

private void paintDayName(final int columnIndex, final Graphics2D graphics, final int absciss, final int ordinate) {
  graphics.setFont(getDayNameFont());
  final LocalDate date = super.parent.getColumnDefinitionAt(columnIndex);
  final int columnWidth = super.parent.getColumnSizeAt(columnIndex);
  final String dayName = StaticWidgetHelper.getSynaptixDateConstantsBundle().shortWeekDays().get(String.valueOf(date.getDayOfWeek()));
  final Rectangle2D rect2 = graphics.getFont().getStringBounds(dayName, graphics.getFontRenderContext());
  final int textAbsciss = (int) (absciss + (columnWidth - rect2.getWidth()) / 2);
  final int textOrdinate = (int) (ordinate + this.dayRowHeight / 4 + rect2.getHeight() / 2);
  graphics.drawString(dayName, textAbsciss, textOrdinate);
}

代码示例来源:origin: actframework/actframework

boolean matches(LocalDate dato) {
  for (FieldPart part : parts) {
    if ("L".equals(part.modifier)) {
      return dato.getDayOfWeek() == part.from && dato.getDayOfMonth() > (dato.dayOfMonth().getMaximumValue() - DAYS_PER_WEEK);
    } else if ("#".equals(part.incrementModifier)) {
      if (dato.getDayOfWeek() == part.from) {
        int num = dato.getDayOfMonth() / 7;
        return part.increment == (dato.getDayOfMonth() % 7 == 0 ? num : num + 1);
      }
      return false;
    } else if (matches(dato.getDayOfWeek(), part)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: qcadoo/mes

private OrderRealizationDay findFirstWorkingDayFrom(final LocalDate orderStartDate, final int startFrom,
    final List<Shift> shifts) {
  Calendar cal = Calendar.getInstance();
  cal.setTime(new Date());
  int daysInYear = cal.getActualMaximum(Calendar.DAY_OF_YEAR);
  for (int offset = startFrom; offset < startFrom + daysInYear; offset++) {
    List<Shift> workingShifts = getShiftsWorkingAt(orderStartDate.plusDays(offset - 1).getDayOfWeek(), shifts);
    if (!workingShifts.isEmpty()) {
      return new OrderRealizationDay(orderStartDate, offset, workingShifts);
    }
  }
  // assuming that no working shifts in period of year length means that client does not use shifts calendar and there won't
  // be any offsets caused by work free time boundaries.
  return new OrderRealizationDay(orderStartDate, startFrom, Collections.<Shift> emptyList());
}

代码示例来源:origin: net.objectlab.kit/datecalc-joda

public boolean isWorkingDay(final LocalDate date) {
  final int dayOfWeek = jodaToCalendarDayConstant(date.getDayOfWeek());
  return isWorkingDayFromCalendar(dayOfWeek);
}

代码示例来源:origin: aol/chronos

boolean matches(LocalDate dato) {
  for (FieldPart part : parts) {
    if ("L".equals(part.modifier)) {
      return dato.getDayOfWeek() == part.from && dato.getDayOfMonth() > (dato.dayOfMonth().getMaximumValue() - DAYS_PER_WEEK);
    } else if ("#".equals(part.incrementModifier)) {
      if (dato.getDayOfWeek() == part.from) {
        int num = dato.getDayOfMonth() / 7;
        return part.increment == (dato.getDayOfMonth() % 7 == 0 ? num : num + 1);
      }
      return false;
    } else if (matches(dato.getDayOfWeek(), part)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.motechproject/motech-platform-commons-date

public static int daysPast(LocalDate localDate, DayOfWeek dayOfWeek) {
  int count = 0;
  LocalDate date = localDate;
  while (date.getDayOfWeek() != dayOfWeek.getValue()) {
    date = date.minusDays(1);
    count++;
  }
  return count;
}

代码示例来源:origin: Appendium/objectlabkit

public boolean isWorkingDay(final LocalDate date) {
  final int dayOfWeek = jodaToCalendarDayConstant(date.getDayOfWeek());
  return isWorkingDayFromCalendar(dayOfWeek);
}

代码示例来源:origin: com.synaptix/SynaptixWidget

private void paintCellBackground(final int columnIndex, final Graphics2D graphics, final Rectangle rectangleToPaint) {
  final LocalDate date = super.parent.getColumnDefinitionAt(columnIndex);
  if (date.getDayOfWeek() == DateTimeConstants.SATURDAY || date.getDayOfWeek() == DateTimeConstants.SUNDAY) {
    graphics.setPaint(GraphicsHelper.buildVerticalGradientPaint(TimelineFooterPanel.class.getName() + "_day_weekEnd", super.configurationContext.getCellHeight(),
        super.colorScheme.getLightColor(), super.colorScheme.getMidColor()));
  } else {
    graphics.setPaint(GraphicsHelper.buildVerticalGradientPaint(TimelineFooterPanel.class.getName() + "_day_normal", super.configurationContext.getCellHeight(),
        super.colorScheme.getUltraLightColor(), super.colorScheme.getLightColor()));
  }
  graphics.fillRect(rectangleToPaint.x, rectangleToPaint.y, rectangleToPaint.width, rectangleToPaint.height);
}

代码示例来源:origin: aaronshan/presto-third-functions

@ScalarFunction("dayOfWeek")
  @Description("Returns the day of week from a date string")
  @SqlType(StandardTypes.INTEGER)
  public static long dayOfWeek(@SqlType(StandardTypes.DATE) long date) {
    try {
      Calendar calendar = Calendar.getInstance();
      calendar.setTimeInMillis(DAYS.toMillis(date));
      LocalDate localDate = LocalDate.fromCalendarFields(calendar);
      return localDate.getDayOfWeek();
    } catch (Exception e) {
      return -1;
    }
  }
}

代码示例来源:origin: com.synaptix/SynaptixWidget

@Override
public Component getCalendarDayCellRendererComponent(JCalendarDay calendarDay, Object value, int column, int row, boolean selected) {
  this.selected = selected;
  LocalDate date = (LocalDate) value;
  numDayLabel.setText(String.valueOf(date.getDayOfMonth()));
  int dayOfWeek = date.getDayOfWeek();
  dayOfWeekLabel.setText(StaticWidgetHelper.getSynaptixDateConstantsBundle().veryShortWeekDays()[dayOfWeek - 1]);
  if (dayOfWeek == DateTimeConstants.SATURDAY || dayOfWeek == DateTimeConstants.SUNDAY) {
    cellLabel.setBackground(Color.LIGHT_GRAY);
  } else {
    cellLabel.setBackground(Color.WHITE);
  }
  return this;
}

代码示例来源:origin: com.synaptix/SynaptixWidget

private void init() {
  LocalDate firstDate = new LocalDate(year, month, 1);
  startDate = firstDate.withDayOfWeek(DateTimeConstants.MONDAY);
  LocalDate lastDate = firstDate.withDayOfMonth(firstDate.dayOfMonth().getMaximumValue());
  LocalDate endDate;
  if (lastDate.getDayOfWeek() != DateTimeConstants.SUNDAY) {
    endDate = lastDate.withDayOfWeek(DateTimeConstants.SUNDAY);
  } else {
    endDate = lastDate;
  }
  Duration d = new Duration(startDate.toDateMidnight(DateTimeZone.UTC), endDate.toDateMidnight(DateTimeZone.UTC));
  nbWeek = ((int) d.getStandardDays() + 1) / 7;
}

代码示例来源:origin: com.synaptix/SynaptixWidget

@Override
  public CellInformation getCellInformation(int rowIndex, int columnIndex) {
    final LocalDate date = super.parent.getColumnDefinitionAt(columnIndex);
    Object obj = null;
    if (rowIndex == 0) {
      obj = date.toString(StaticWidgetHelper.getSynaptixDateConstantsBundle().hierarchicalMonthDisplay());
    } else if (rowIndex == 1) {
      obj = StaticWidgetHelper.getSynaptixDateConstantsBundle().week(date.getWeekOfWeekyear());
    } else if (rowIndex == 2) {
      obj = StaticWidgetHelper.getSynaptixDateConstantsBundle().shortWeekDays().get(String.valueOf(date.getDayOfWeek())) + String.valueOf(date.getDayOfMonth());
    }
    return new CellInformation(obj);
  }
}

相关文章