Mercurial > dive4elements > framework
view artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/DateUtils.java @ 585:0960b825516a 3.2.x tip
Ensure the build does not fail due to non-ASCII characters
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 15 Nov 2023 10:34:52 +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); } }