Java Code Examples for java.time.DayOfWeek#valueOf()

The following examples show how to use java.time.DayOfWeek#valueOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java    From schedge with MIT License 6 votes vote down vote up
public static DayOfWeek parseDayOfWeek(String dayOfWeek) {
  switch (dayOfWeek) {
  case "Mo":
    return DayOfWeek.MONDAY;
  case "Tu":
    return DayOfWeek.TUESDAY;
  case "We":
    return DayOfWeek.WEDNESDAY;
  case "Th":
    return DayOfWeek.THURSDAY;
  case "Fr":
    return DayOfWeek.FRIDAY;
  case "Sa":
    return DayOfWeek.SATURDAY;
  case "Su":
    return DayOfWeek.SUNDAY;
  default:
    return DayOfWeek.valueOf(dayOfWeek);
  }
}
 
Example 2
Source File: CalendarLoader.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void loadDayNames(Calendar resultComponent, Element element) {
    Element dayNames = element.element("dayNames");
    if (dayNames == null) {
        return;
    }

    Map<DayOfWeek, String> dayNamesMap = new HashMap<>();
    for (Element dayName : dayNames.elements("day")) {

        String dayKey = dayName.attributeValue("dayOfWeek");
        DayOfWeek dayOfWeek = null;
        if (StringUtils.isNotEmpty(dayKey)) {
            dayOfWeek = DayOfWeek.valueOf(dayKey);
        }

        String dayValue = dayName.attributeValue("value");
        if (StringUtils.isNotEmpty(dayValue)) {
            if (dayOfWeek != null) {
                dayValue = loadResourceString(dayValue);
                dayNamesMap.put(dayOfWeek, dayValue);
            }
        }
    }
    resultComponent.setDayNames(dayNamesMap);
}
 
Example 3
Source File: HoltWintersDetector.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
@Override
public void init(HoltWintersDetectorSpec spec, InputDataFetcher dataFetcher) {
  this.period = spec.getPeriod();
  this.alpha = spec.getAlpha();
  this.beta = spec.getBeta();
  this.gamma = spec.getGamma();
  this.dataFetcher = dataFetcher;
  this.pattern = spec.getPattern();
  this.smoothing = spec.getSmoothing();
  this.sensitivity = spec.getSensitivity();
  this.monitoringGranularity = spec.getMonitoringGranularity();

  if (this.monitoringGranularity.endsWith(TimeGranularity.MONTHS) || this.monitoringGranularity.endsWith(TimeGranularity.WEEKS)) {
    this.timeGranularity = MetricSlice.NATIVE_GRANULARITY;
  } else {
    this.timeGranularity = TimeGranularity.fromString(this.monitoringGranularity);
  }
  if (this.monitoringGranularity.endsWith(TimeGranularity.WEEKS)) {
    this.weekStart = DayOfWeek.valueOf(spec.getWeekStart());
  }
}
 
Example 4
Source File: PercentageChangeRuleDetector.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
@Override
public void init(PercentageChangeRuleDetectorSpec spec, InputDataFetcher dataFetcher) {
  this.percentageChange = spec.getPercentageChange();
  this.dataFetcher = dataFetcher;
  String timezone = spec.getTimezone();
  String offset = spec.getOffset();
  this.baseline = BaselineParsingUtils.parseOffset(offset, timezone);
  this.pattern = Pattern.valueOf(spec.getPattern().toUpperCase());

  this.monitoringGranularity = spec.getMonitoringGranularity();
  if (this.monitoringGranularity.endsWith(TimeGranularity.MONTHS) || this.monitoringGranularity.endsWith(TimeGranularity.WEEKS)) {
    this.timeGranularity = MetricSlice.NATIVE_GRANULARITY;
  } else {
    this.timeGranularity = TimeGranularity.fromString(spec.getMonitoringGranularity());
  }
  if (this.monitoringGranularity.endsWith(TimeGranularity.WEEKS)) {
    this.weekStart = DayOfWeek.valueOf(spec.getWeekStart());
  }
}