Mercurial > dive4elements > framework
view artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/DateUtils.java @ 549:e781b847fdca 3.2.2
Added new File/NS-aware/Entity-Resolver signature for XMLUtils.parseDocument.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 22 Feb 2016 17:25:21 +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); } }