summaryrefslogtreecommitdiffstats
path: root/src/org/uic/ticket/api/asn/omv2/DateTimeUtils.java
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2021-02-25 11:02:26 +0100
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2021-02-25 11:02:26 +0100
commit425bd35c736b7e1c0dbe5b3f9162e195b3be6018 (patch)
treebc4668aa125fb0a15518d464a1738c6b05e56d07 /src/org/uic/ticket/api/asn/omv2/DateTimeUtils.java
parentissuerOnLine changed from int to Integer as it is optional (diff)
downloadUIC-barcode-1.2.tar
UIC-barcode-1.2.tar.gz
UIC-barcode-1.2.tar.bz2
UIC-barcode-1.2.tar.lz
UIC-barcode-1.2.tar.xz
UIC-barcode-1.2.tar.zst
UIC-barcode-1.2.zip
Diffstat (limited to 'src/org/uic/ticket/api/asn/omv2/DateTimeUtils.java')
-rw-r--r--src/org/uic/ticket/api/asn/omv2/DateTimeUtils.java198
1 files changed, 0 insertions, 198 deletions
diff --git a/src/org/uic/ticket/api/asn/omv2/DateTimeUtils.java b/src/org/uic/ticket/api/asn/omv2/DateTimeUtils.java
deleted file mode 100644
index 005e27d..0000000
--- a/src/org/uic/ticket/api/asn/omv2/DateTimeUtils.java
+++ /dev/null
@@ -1,198 +0,0 @@
-package org.uic.ticket.api.asn.omv2;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.concurrent.TimeUnit;
-
-public class DateTimeUtils {
-
- public static Long getDateDifference(Date issuingDate, Date localDate) {
-
- if (issuingDate == null || localDate == null) return null;
-
- Calendar issuingCal = Calendar.getInstance();
- issuingCal.clear();
- issuingCal.setTime(issuingDate);
- issuingCal.setTimeZone(TimeZone.getTimeZone("UTC"));
- issuingCal.set(Calendar.HOUR_OF_DAY, 0);
- issuingCal.set(Calendar.MINUTE, 0);
- issuingCal.set(Calendar.SECOND, 0);
- issuingCal.set(Calendar.MILLISECOND, 0);
-
- Calendar fromCal = Calendar.getInstance();
- fromCal.clear();
- fromCal.setTime(localDate);
- fromCal.setTimeZone(TimeZone.getTimeZone("UTC"));
- fromCal.set(Calendar.HOUR_OF_DAY, 0);
- fromCal.set(Calendar.MINUTE, 0);
- fromCal.set(Calendar.SECOND, 0);
- fromCal.set(Calendar.MILLISECOND, 0);
-
- long diff = localDate.getTime() - issuingDate.getTime();
- long dayDiff = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
-
- return new Long(dayDiff);
-
- }
-
- public static Date getLocalDateFromDifference(Date issuingDate, int diff , Long time ) {
-
- if (issuingDate == null) return null;
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.setTime(issuingDate);
- cal.add(Calendar.DAY_OF_YEAR, diff);
-
- if (time != null) {
- int hours = time.intValue() / 60;
- int minutes = time.intValue() - hours * 60;
- cal.set(Calendar.HOUR_OF_DAY, hours);
- cal.set(Calendar.MINUTE,minutes);
- }
-
- return cal.getTime();
-
- }
-
-
- public static void setTime(Calendar cal, Long time){
-
- if (time != null) {
- int hours = time.intValue() / 60;
- int minutes = time.intValue() - hours * 60;
- cal.set(Calendar.HOUR_OF_DAY, hours);
- cal.set(Calendar.MINUTE,minutes);
- }
-
-
- }
-
- public static Long getTime (Calendar cal) {
-
- if (cal == null ||
- !cal.isSet(Calendar.HOUR_OF_DAY) ||
- !cal.isSet(Calendar.MINUTE) ) {
- return null;
- }
-
- int time = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
- if (time > 0) {
- return new Long (time );
- }
- return null;
- }
-
- public static Long getTime (Date date) {
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.setTime(date);
-
- if (cal == null ||
- !cal.isSet(Calendar.HOUR_OF_DAY) ||
- !cal.isSet(Calendar.MINUTE) ) {
- return null;
- }
-
- int time = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
- if (time > 0) {
- return new Long (time );
- }
- return null;
- }
-
- public static Date getDate(Date issuingDate, Long date, Long time){
-
- if (issuingDate == null) return null;
-
- if (date == null) {
- date = 0L;
- }
-
- Calendar issuingCal = Calendar.getInstance();
- issuingCal.clear();
- issuingCal.setTime(issuingDate);
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.set(Calendar.YEAR,issuingCal.get(Calendar.YEAR) );
- cal.set(Calendar.DAY_OF_YEAR,issuingCal.get(Calendar.DAY_OF_YEAR) );
-
- cal.add(Calendar.DAY_OF_YEAR, date.intValue());
-
- DateTimeUtils.setTime(cal,time);
-
- return cal.getTime();
-
- }
-
-
-
- /**
- * Gets the UTC offset.
- *
- * @param date and time of the issuing date
- * @param date and time of the departure
- * @return the UTC offset in multiples of 15 minutes
- * the offset needs to be added to local time to get the UTC time (UTC = local + offset)
- */
- public static Long getUTCoffset(Date local) {
-
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.setTime(local);
-
- /*
- * Returns the amount of time in milliseconds to add to UTC to get standard time in this
- * time zone. Because this value is not affected by daylight saving time, it is called raw offset.
- * If an underlying TimeZone implementation subclass supports historical GMT offset changes, the method
- * returns the raw offset value of the current date. In Honolulu, for example, its raw offset
- * changed from GMT-10:30 to GMT-10:00 in 1947, and this method
- * always returns -36000000 milliseconds (i.e., -10 hours).
- */
- int minuteOffset = - cal.getTimeZone().getRawOffset()/ ( 1000 * 60 * 15 );
-
- return new Long (minuteOffset);
-
- }
-
- public static Date getUTCDate(Date issuingDate, Long date, Long time, Long UTCOffset) {
-
- if (issuingDate == null) return null;
-
- if (UTCOffset == null) return null;
-
- if (time == null) return null;
-
- if (date == null) {
- date = 0L;
- }
-
- Calendar issuingCal = Calendar.getInstance();
- issuingCal.clear();
- issuingCal.setTime(issuingDate);
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.set(Calendar.YEAR,issuingCal.get(Calendar.YEAR) );
- cal.set(Calendar.DAY_OF_YEAR,issuingCal.get(Calendar.DAY_OF_YEAR) );
- cal.add(Calendar.DAY_OF_YEAR, date.intValue());
-
- int hours = time.intValue() / 60;
- int minutes = time.intValue() - hours * 60;
- cal.set(Calendar.HOUR_OF_DAY, hours);
- cal.set(Calendar.MINUTE,minutes);
-
- cal.add(Calendar.MINUTE, (int) (UTCOffset * 15) );
-
- cal.setTimeZone(TimeZone.getTimeZone("UTC"));
-
- return cal.getTime();
-
- }
-
-
-}