Java examples for java.time:Month
plus Months to java.util.Date via LocalDate
//package com.java2s; import java.time.LocalDate; import java.time.ZoneId; import java.util.Date; public class Main { public static Date plusMonths(Date date, int months) { return localDateToDate(dateToLocalDate(date).plusMonths(months)); }/*from w ww.ja va2s . co m*/ public static Date localDateToDate(LocalDate localDate) { return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()) .toInstant()); } public static LocalDate dateToLocalDate(Date date) { return date.toInstant().atZone(ZoneId.systemDefault()) .toLocalDate(); } }