src/main/java/com/zandero/utils/InstantTimeUtils.java
public static Instant getMonthEnd(Instant time) {

		Assert.notNull(time, "Missing date time");
		LocalDateTime dateTime = LocalDateTime.ofInstant(time, ZoneOffset.UTC);
		dateTime = dateTime.withDayOfMonth(1).withHour(23).withMinute(59).withSecond(59).with(ChronoField.MILLI_OF_SECOND, 999);
		dateTime = dateTime.plus(1, ChronoUnit.MONTHS).minus(1, ChronoUnit.DAYS);
		return dateTime.toInstant(ZoneOffset.UTC);
	}
public static Instant getMonthEnd(Instant time) {

		Assert.notNull(time, "Missing date time");
		LocalDateTime dateTime = LocalDateTime.ofInstant(time, ZoneOffset.UTC);
		dateTime = dateTime.withDayOfMonth(1).withHour(23).withMinute(59).withSecond(59).with(ChronoField.MILLI_OF_SECOND, 999);
		dateTime = dateTime.plus(1, ChronoUnit.MONTHS).minus(1, ChronoUnit.DAYS);
		return dateTime.toInstant(ZoneOffset.UTC);
	}
Returns last millisecond of last day in month ... +1 = next first day in month

@param time to get last second in month
@return last millisecond of month for given time