Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/utils/DateUtil.java @ 7927:07cc4cd9233e
Add new DateUtil class.
author | "Tom Gottfried <tom@intevation.de>" |
---|---|
date | Thu, 12 Jun 2014 12:21:55 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
7926:e3b74679b2b4 | 7927:07cc4cd9233e |
---|---|
1 /* Copyright (C) 2014 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.utils; | |
10 | |
11 import java.util.Date; | |
12 import java.util.Calendar; | |
13 | |
14 public final class DateUtil { | |
15 | |
16 private DateUtil() { | |
17 } | |
18 | |
19 /** Create Date on first moment (1st jan) of given year. */ | |
20 public static Date getStartDateFromYear(int year) { | |
21 Calendar cal = Calendar.getInstance(); | |
22 cal.clear(); | |
23 cal.set(year, 0, 1, 0, 0, 0); | |
24 | |
25 return cal.getTime(); | |
26 } | |
27 | |
28 | |
29 /** Create Date on last moment (31st dec) of given year. */ | |
30 public static Date getEndDateFromYear(int year) { | |
31 Calendar cal = Calendar.getInstance(); | |
32 cal.clear(); | |
33 cal.set(year, 11, 31, 23, 59, 59); | |
34 | |
35 return cal.getTime(); | |
36 } | |
37 } |