Commit 77ed52cb authored by Christoph Niemann's avatar Christoph Niemann Committed by GitHub
Browse files

Merge pull request #1 from b0e/master

[DateHelper] added getCurrentMonth and getNow
parents cbcac411 839bebdd
......@@ -8,6 +8,7 @@ import java.util.Date;
* Class helping jasper to generate reports for the following periods
* - last week
* - last month
* - current month
* - last quarter
* - last year
*
......@@ -28,8 +29,30 @@ public class DateHelper {
System.out.println("Last-Quarter End: " + getLastQuarterEnd());
System.out.println("Last-Year Start: " + getLastYearStart());
System.out.println("Last-Year End: " + getLastYearEnd());
System.out.println("Current-Month Start: " + getCurrentMonthStart());
System.out.println("Now: " + getNow());
}
static public Timestamp getCurrentMonthStart() {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Timestamp ts = new Timestamp(cal.getTime().getTime());
return ts;
}
static public Timestamp getNow() {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
Timestamp ts = new Timestamp(cal.getTime().getTime());
return ts;
}
static public Timestamp getLastWeekStart() {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment