Mercurial > dive4elements > framework
view artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/DateUtils.java @ 498:1f1f14c932ed 3.0.14
Framework: Added StringUtils.indexOf(needle, haystack) method.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 08 Aug 2013 17:01:58 +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); } }