| 1258 | * @since 4.19 |
| 1259 | */ |
| 1260 | public PlainTimestamp plus( |
| 1261 | long amount, |
| 1262 | CalendarUnit unit |
| 1263 | ) { |
| 1264 | |
| 1265 | if (unit == null) { |
| 1266 | throw new NullPointerException("Missing unit."); |
| 1267 | } else if (amount == 0) { |
| 1268 | return this; |
| 1269 | } |
| 1270 | |
| 1271 | try { |
| 1272 | return CALENDAR_UNIT_RULE_MAP.get(unit).addTo(this, amount); |
| 1273 | } catch (IllegalArgumentException iae) { |
| 1274 | ArithmeticException ex = new ArithmeticException("Result beyond boundaries of time axis."); |
| 1275 | ex.initCause(iae); |
| 1276 | throw ex; |
| 1277 | } |
| 1278 | |
| 1279 | } |
| 1280 | |
| 1281 | /** |
| 1282 | * <p>Adds given amount in units to this timestamp and yields the result of addition. </p> |