summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper
diff options
context:
space:
mode:
authorJonathan Bauer2015-08-25 14:58:20 +0200
committerJonathan Bauer2015-08-25 14:58:20 +0200
commit7a7edd6f989ade3dfad56039633a0b02a6d7ea84 (patch)
treefdb5c64466ec3189690613bd03417ac04f10e842 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper
parent[client] null check the result in UserCache (diff)
downloadtutor-module-7a7edd6f989ade3dfad56039633a0b02a6d7ea84.tar.gz
tutor-module-7a7edd6f989ade3dfad56039633a0b02a6d7ea84.tar.xz
tutor-module-7a7edd6f989ade3dfad56039633a0b02a6d7ea84.zip
[client] check maxValidity for lecture when creating them
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/DateTimeHelper.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/DateTimeHelper.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/DateTimeHelper.java
index 6c404f9b..3c6710de 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/DateTimeHelper.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/DateTimeHelper.java
@@ -8,6 +8,11 @@ import javax.swing.JSpinner;
import org.jdatepicker.impl.JDatePickerImpl;
public class DateTimeHelper {
+ private static Calendar calendar = null;
+ static {
+ if (calendar == null)
+ calendar = Calendar.getInstance();
+ }
/**
* Returns the Date composed of the given datePicker's date and the given timeSpinner's time
*
@@ -22,13 +27,17 @@ public class DateTimeHelper {
int days = datePicker.getModel().getDay();
// start time from the Spinner
Date time = (Date) timeSpinner.getValue();
- Calendar cal = Calendar.getInstance();
- cal.setTime(time);
- int hours = cal.get(Calendar.HOUR_OF_DAY);
- int minutes = cal.get(Calendar.MINUTE);
+ calendar.setTime(time);
+ int hours = calendar.get(Calendar.HOUR_OF_DAY);
+ int minutes = calendar.get(Calendar.MINUTE);
// build the time from the single values
- cal.set(years, months, days, hours, minutes);
- Date date = cal.getTime();
+ calendar.set(years, months, days, hours, minutes);
+ Date date = calendar.getTime();
return date;
}
+ public static Date addDaysTo(Date start, int days) {
+ calendar.setTime(start);
+ calendar.add(Calendar.DAY_OF_MONTH, days);
+ return calendar.getTime();
+ }
}