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

Method addDays

base/src/main/java/net/time4j/PlainDate.java:2052–2087  ·  view source on GitHub ↗
(
        PlainDate date,
        long amount
    )

Source from the content-addressed store, hash-verified

2050 }
2051
2052 private static PlainDate addDays(
2053 PlainDate date,
2054 long amount
2055 ) {
2056
2057 long dom = MathUtils.safeAdd(date.dayOfMonth, amount);
2058 Weekday weekday = null;
2059 boolean hasDOW = (date.weekday != null);
2060
2061 if (hasDOW) {
2062 if (amount == 1) {
2063 weekday = date.weekday.next();
2064 } else if (amount == 7) {
2065 weekday = date.weekday;
2066 }
2067 }
2068
2069 if ((dom >= 1) && (dom <= 28)) {
2070 if (hasDOW && (weekday == null)) {
2071 weekday = date.weekday.roll((int) amount);
2072 }
2073 return PlainDate.create(date.year, date.month, (int) dom, weekday, false);
2074 }
2075
2076 long doy = MathUtils.safeAdd(date.getDayOfYear(), amount);
2077
2078 if ((doy >= 1) && (doy <= 365)) {
2079 if (hasDOW && (weekday == null)) {
2080 weekday = date.weekday.roll((int) amount);
2081 }
2082 return PlainDate.ofYearDay(date.year, (int) doy, weekday);
2083 }
2084
2085 return TRANSFORMER.transform(MathUtils.safeAdd(date.getDaysSinceUTC(), amount));
2086
2087 }
2088
2089 private static void fill(
2090 Map<String, Object> map,

Callers 2

doAddMethod · 0.95
withDayOfWeekMethod · 0.95

Calls 8

safeAddMethod · 0.95
createMethod · 0.95
ofYearDayMethod · 0.95
getDaysSinceUTCMethod · 0.80
transformMethod · 0.65
nextMethod · 0.45
rollMethod · 0.45
getDayOfYearMethod · 0.45

Tested by

no test coverage detected