return GregorianCalendar.from(LocalDateTime .from(ta) .with(WeekFields.ISO.weekOfYear(), y) .with(WeekFields.ISO.weekOfWeekBasedYear(), w) .atZone(ZoneId.systemDefault()));
int week = 1; int year = 2016; WeekFields weekFields = WeekFields.of(Locale.getDefault()); LocalDateTime ldt = LocalDateTime.now() .withYear(year) .with(weekFields.weekOfYear(), week) .with(weekFields.dayOfWeek(), 1); System.out.println(ldt);
@Override public void enterPW(StrfTimeParser.PWContext ctx) { // %W The week number of the current year as a decimal number, range 00 to 53, // starting with the first Monday as the first day of week 01. builder.appendValue(WeekFields.ISO.weekOfYear(), 2); }
@Override public void enterPV(StrfTimeParser.PVContext ctx) { // %V The ISO 8601 week number (see NOTES) of the current year as a decimal number, range 01 to 53, // where week 1 is the first week that has at least 4 days in the new year. See also %U and %W. builder.appendValue(WeekFields.ISO.weekOfYear()); }
/** * Returns the number of displayed time steps in the specified time range type. * * @param timeType the time range type to be displayed * @param year the year to be displayed * @return number of time steps */ private int getTimeStepCount(TimeRangeType timeType, int year) { switch (timeType) { case LAST_12_MONTHS: return 13; case MONTHS_OF_YEAR: return 12; case WEEKS_OF_YEAR: // Workaround for a JFreeChart problem: use the Year instead // of Week class for the bottom axis, otherwise there will be // format problems on the axis (the first week is often "52") // => get number of weeks for the specified year (mostly 52, sometimes 53) LocalDate dateinYear = LocalDate.of(year, 1, 15); WeekFields weekField = getWeekFieldsForWeekStart(); return (int) dateinYear.range(weekField.weekOfYear()).getMaximum(); case LAST_10_YEARS: return 10; default: throw new IllegalArgumentException("Unknown TimeRangeType!"); } }
return date.get(wf.weekOfYear());
return GregorianCalendar.from(LocalDateTime .from(ta) .with(WeekFields.ISO.weekOfYear(), y) .with(WeekFields.ISO.weekOfWeekBasedYear(), w) .atZone(ZoneId.systemDefault()));
return GregorianCalendar.from(LocalDateTime .from(ta) .with(WeekFields.ISO.weekOfYear(), y) .with(WeekFields.ISO.weekOfWeekBasedYear(), w) .atZone(ZoneId.systemDefault()));
return GregorianCalendar.from(LocalDateTime .from(ta) .with(WeekFields.ISO.weekOfYear(), y) .with(WeekFields.ISO.weekOfWeekBasedYear(), w) .atZone(ZoneId.systemDefault()));