view backend/src/main/java/org/dive4elements/river/backend/utils/DateUtil.java @ 8763:8179cca1796a

Upgrade to DBCP 2.1.1 DBCP 2 needs at least Java 7. We are no longer compatible with Java 6.
author Tom Gottfried <tom@intevation.de>
date Fri, 14 Aug 2015 18:24:04 +0200
parents 3bb1c62ad732
children
line wrap: on
line source
/* Copyright (C) 2014 by Bundesanstalt für Gewässerkunde
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU AGPL (>=v3)
 * and comes with ABSOLUTELY NO WARRANTY! Check out the
 * documentation coming with Dive4Elements River for details.
 */

package org.dive4elements.river.backend.utils;

import java.util.Date;
import java.util.Calendar;

public final class DateUtil {

    private DateUtil() {
    }

    /** Create Date on first moment (1st jan) of given year. */
    public static Date getStartDateFromYear(int year) {
        Calendar cal = Calendar.getInstance();
        cal.clear();
        cal.set(year, 0, 1, 0, 0, 0);

        return cal.getTime();
    }


    /** Create Date on last moment (31st dec) of given year. */
    public static Date getEndDateFromYear(int year) {
        Calendar cal = Calendar.getInstance();
        cal.clear();
        cal.set(year, 11, 31, 23, 59, 59);

        return cal.getTime();
    }
}

http://dive4elements.wald.intevation.org