MCPcopy Create free account
hub / github.com/MenoData/Time4J / withValue

Method withValue

base/src/main/java/net/time4j/Weekmodel.java:1275–1299  ·  view source on GitHub ↗
(
            T context,
            Weekday value,
            boolean lenient
        )

Source from the content-addressed store, hash-verified

1273 }
1274
1275 @Override
1276 public T withValue(
1277 T context,
1278 Weekday value,
1279 boolean lenient
1280 ) {
1281
1282 if (value == null) {
1283 throw new IllegalArgumentException("Missing weekday.");
1284 }
1285
1286 PlainDate date = context.get(CALENDAR_DATE);
1287 long utcDays = date.getDaysSinceUTC();
1288 Weekday current = getDayOfWeek(utcDays);
1289
1290 if (value == current) {
1291 return context;
1292 }
1293
1294 int old = current.getValue(this.element.getModel());
1295 int neu = value.getValue(this.element.getModel());
1296 date = date.withDaysSinceUTC(utcDays + neu - old);
1297 return context.with(CALENDAR_DATE, date);
1298
1299 }
1300
1301 @Override
1302 public ChronoElement<?> getChildAtFloor(T context) {

Callers 1

isValidMethod · 0.95

Calls 8

getDaysSinceUTCMethod · 0.95
getValueMethod · 0.95
withDaysSinceUTCMethod · 0.95
getMethod · 0.65
getValueMethod · 0.65
withMethod · 0.65
getDayOfWeekMethod · 0.45
getModelMethod · 0.45

Tested by

no test coverage detected