Mercurial > dive4elements > framework
view artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/DateUtils.java @ 533:3d9d6d61d0c6 3.1.7
Use the real artifact name.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 25 Sep 2014 11:04:34 +0200 |
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); } }