I want to convert the current date to integer value. By default, it returns long. When I try to convert long to integer, and afterwards I convert the integer value to date,
Java Date
to int
conversion:
public static final String DATE_FORMAT_INT = "yyyyMMdd";
public static String format(Date date, String format) {
return isNull(date) ?
null : new SimpleDateFormat(format).format(date);
}
public static Integer getDateInt(Date date) {
if (isNull(date)) {
throw new IllegalArgumentException("Date must not be NULL");
}
return parseInt(format(date, DATE_FORMAT_INT));
}