Mercurial > dive4elements > framework
view artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/DateUtils.java @ 570:584591f8203c 3.2.x
Upgrade to Log4j 2
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Mon, 28 Feb 2022 17:41:14 +0100 |
parents | 415df0fc4fa1 |
children | 1c2ce0501305 |
line wrap: on
line source
package org.dive4elements.artifacts.common.utils; import java.util.Calendar; import java.util.Date; public class DateUtils { private DateUtils() { } /** * This function extracts the year as int value from <i>date</i>. * * @param date The source date. * * @return the year as integer or -1 if date is empty. */ public static int getYearFromDate(Date date) { if (date == null) { return -1; } Calendar cal = Calendar.getInstance(); cal.setTime(date); return cal.get(Calendar.YEAR); } }