dateDiff(Date, int) -> add(Date, int) 수정, getDates(Date, int) 추가

master
mjkhan21 2 months ago
parent 21e17b9cd6
commit d88985f7ee

@ -1,6 +1,9 @@
package cokr.xit.foundation.component;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.IntStream;
import javax.annotation.Resource;
@ -92,12 +95,32 @@ public abstract class AbstractBean extends AbstractComponent {
return isEmpty(logName) ? super.log() : Log.get(logName);
}
/** Date Date .
/** .
* @param date
* @param days
* @return Date
*/
protected static Date dateDiff(Date date, int days) {
protected static Date add(Date date, int days) {
return new Date(date.getTime() + (1000L * 60L * 60L * 24L * days));
}
/** .
* @param date
* @param days
* <ul><li>0 </li>
* <li>0 </li>
* <li>0 </li>
* </ul>
* @return
*/
protected static List<Date> getDates(Date date, int days) {
if (date == null)
return Collections.emptyList();
if (days == 0)
return List.of(date);
return IntStream.range(0, Math.abs(days)).boxed()
.map(num -> add(date, days > 0 ? num : -num))
.toList();
}
}
Loading…
Cancel
Save