summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/CarCarriageReservationData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/CountermarkData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/FIPTicketData.java20
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/IncludedOpenTicketType.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/IssuingData.java3
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java21
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/ParkingGroundData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/PassData.java450
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/ReservationData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/StationPassageData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/TrainLinkType.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/ValidityPeriodType.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/uicBarcodeV1finalDelayConfirmation1.3.asn35
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/CountermarkData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/DateTimeUtils.java198
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/FIPTicketData.java20
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java21
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/PassData.java20
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/StationPassageData.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java1
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv2/uicBarcodeFCBv2.0.asn2
-rw-r--r--src/org/uic/barcode/ticket/api/test/DateTimeUtilsTest.java2
-rw-r--r--src/org/uic/barcode/ticket/api/test/PassTestTicketV1.java150
-rw-r--r--src/org/uic/barcode/ticket/api/test/PassTimeZoneTestTicketCase1V1.java170
-rw-r--r--src/org/uic/barcode/ticket/api/test/PassTimeZoneTestTicketCase2V1.java167
-rw-r--r--src/org/uic/barcode/ticket/api/test/PassTimeZoneTestTicketCase3V1.java206
-rw-r--r--src/org/uic/barcode/ticket/api/test/PassTimeZoneTestV1.java419
-rw-r--r--src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java14
-rw-r--r--src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java16
-rw-r--r--src/org/uic/barcode/ticket/api/utils/DateTimeUtils.java (renamed from src/org/uic/barcode/ticket/api/asn/omv1/DateTimeUtils.java)69
-rw-r--r--src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java15
-rw-r--r--src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java7
37 files changed, 1720 insertions, 321 deletions
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/CarCarriageReservationData.java b/src/org/uic/barcode/ticket/api/asn/omv1/CarCarriageReservationData.java
index 97ac3d5..1eb0533 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/CarCarriageReservationData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/CarCarriageReservationData.java
@@ -34,6 +34,7 @@ import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCarrierNum;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/CountermarkData.java b/src/org/uic/barcode/ticket/api/asn/omv1/CountermarkData.java
index c223900..76625d4 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/CountermarkData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/CountermarkData.java
@@ -32,6 +32,7 @@ import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/FIPTicketData.java b/src/org/uic/barcode/ticket/api/asn/omv1/FIPTicketData.java
index 47e4959..0171ecf 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/FIPTicketData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/FIPTicketData.java
@@ -32,6 +32,7 @@ import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
public class FIPTicketData extends Object {
public FIPTicketData() {
@@ -275,20 +276,17 @@ public class FIPTicketData extends Object {
}
- public void setActivatedDays(Collection<Date> dates, Date issuingDate){
+
+ public void addActivatedDays(Collection<Long> days) {
+
+ if (days == null || days.isEmpty()) return;
- if (this.activatedDay != null) {
- this.activatedDay.clear();
- } else {
- this.activatedDay= new SequenceOfActivatedDays();
+ if (this.activatedDay == null) {
+ this.activatedDay = new SequenceOfActivatedDays();
}
- if (dates != null && !dates.isEmpty()) {
-
- for (Date day : dates) {
- this.addActivatedDay(issuingDate, day);
- }
-
+ for (Long l : days) {
+ this.activatedDay.add(l);
}
}
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/IncludedOpenTicketType.java b/src/org/uic/barcode/ticket/api/asn/omv1/IncludedOpenTicketType.java
index 6b6c538..a4b4049 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/IncludedOpenTicketType.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/IncludedOpenTicketType.java
@@ -31,6 +31,7 @@ import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
public class IncludedOpenTicketType extends Object {
public IncludedOpenTicketType() {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/IssuingData.java b/src/org/uic/barcode/ticket/api/asn/omv1/IssuingData.java
index cb2d126..5f0e345 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/IssuingData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/IssuingData.java
@@ -351,7 +351,8 @@ public class IssuingData extends Object {
}
- return cal.getTime();
+ Date d = cal.getTime();
+ return d;
}
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java b/src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java
index 13ceb84..0e7a044 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java
@@ -35,6 +35,7 @@ import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
@@ -605,25 +606,21 @@ public class OpenTicketData extends Object {
}
-
- public void setActivatedDays(Collection<Date> dates, Date issuingDate){
+ public void addActivatedDays(Collection<Long> days) {
+
+ if (days == null || days.isEmpty()) return;
- if (this.activatedDay != null) {
- this.activatedDay.clear();
- } else {
- this.activatedDay= new SequenceOfActivatedDays();
+ if (this.activatedDay == null) {
+ this.activatedDay = new SequenceOfActivatedDays();
}
- if (dates != null && !dates.isEmpty()) {
-
- for (Date day : dates) {
- this.addActivatedDay(issuingDate, day);
- }
-
+ for (Long l : days) {
+ this.activatedDay.add(l);
}
}
+
public void addActivatedDay(Date issuingDate, Date day){
Long dayDiff = DateTimeUtils.getDateDifference(issuingDate, day);
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/ParkingGroundData.java b/src/org/uic/barcode/ticket/api/asn/omv1/ParkingGroundData.java
index b6be1a4..8119502 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/ParkingGroundData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/ParkingGroundData.java
@@ -30,6 +30,7 @@ import org.uic.barcode.asn1.datatypes.HasExtensionMarker;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/PassData.java b/src/org/uic/barcode/ticket/api/asn/omv1/PassData.java
index 6a56a40..1139a80 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/PassData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/PassData.java
@@ -34,127 +34,169 @@ import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class PassData.
+ */
@Sequence
@HasExtensionMarker
public class PassData extends Object {
+
+ /**
+ * Instantiates a new pass data.
+ */
public PassData() {
}
+ /** The reference num. */
@FieldOrder(order = 0)
@Asn1Optional public Asn1BigInteger referenceNum;
+ /** The reference IA 5. */
@FieldOrder(order = 1)
@RestrictedString(CharacterRestriction.IA5String)
@Asn1Optional public String referenceIA5;
+ /** The product owner num. */
@FieldOrder(order = 2)
@IntRange(minValue=1,maxValue=32000)
@Asn1Optional public Long productOwnerNum;
+ /** The product owner IA 5. */
@FieldOrder(order = 3)
@RestrictedString(CharacterRestriction.IA5String)
@Asn1Optional public String productOwnerIA5;
+ /** The product id num. */
@FieldOrder(order = 4)
@IntRange(minValue=1,maxValue=32000)
@Asn1Optional public Long productIdNum;
+ /** The product id IA 5. */
@FieldOrder(order = 5)
@RestrictedString(CharacterRestriction.IA5String)
@Asn1Optional public String productIdIA5;
+ /** The pass type. */
@FieldOrder(order = 6)
@IntRange(minValue=1,maxValue=250)
@Asn1Optional public Long passType;
+ /** The pass description. */
@FieldOrder(order = 7)
@RestrictedString(CharacterRestriction.UTF8String)
@Asn1Optional public String passDescription;
+ /** The class code. */
@FieldOrder(order = 8)
@Asn1Default (value="second")
@Asn1Optional public TravelClassType classCode;
+ /** The valid from day. */
@FieldOrder(order = 9)
@IntRange(minValue=-1,maxValue=700)
@Asn1Optional public Long validFromDay;
+ /** The valid from time. */
@FieldOrder(order = 10)
@IntRange(minValue=0,maxValue=1440)
@Asn1Optional public Long validFromTime;
+ /** The valid from UTC offset. */
@FieldOrder(order = 11)
@IntRange(minValue=-60, maxValue=60)
@Asn1Optional public Long validFromUTCOffset;
+ /** The valid until day. */
@FieldOrder(order = 12)
@IntRange(minValue=0,maxValue=370)
@Asn1Optional public Long validUntilDay;
+ /** The valid until time. */
@FieldOrder(order = 13)
@IntRange(minValue=0,maxValue=1440)
@Asn1Optional public Long validUntilTime;
+ /** The valid until UTC offset. */
@FieldOrder(order = 14)
@IntRange(minValue=-60, maxValue=60)
@Asn1Optional public Long validUntilUTCOffset;
+ /** The validity period details. */
@FieldOrder(order = 15)
@Asn1Optional public ValidityPeriodDetailType validityPeriodDetails;
+ /** The number of validity days. */
@FieldOrder(order = 16)
@IntRange(minValue=0,maxValue=370)
@Asn1Optional public Long numberOfValidityDays;
+ /** The number of possible trips. */
@FieldOrder(order = 17)
@IntRange(minValue=1,maxValue=250)
@Asn1Optional public Long numberOfPossibleTrips;
+ /** The number of days of travel. */
@FieldOrder(order = 18)
@IntRange(minValue=1,maxValue=250)
@Asn1Optional public Long numberOfDaysOfTravel;
+ /** The activated day. */
@FieldOrder(order = 19)
@Asn1Optional public SequenceOfActivatedDays activatedDay;
+ /** The countries. */
@FieldOrder(order = 20)
@Asn1Optional public SequenceOfCountries countries;
+ /** The included carriers num. */
@FieldOrder(order = 21)
@Asn1Optional public SequenceOfCarrierNum includedCarriersNum;
+ /** The included carriers IA 5. */
@FieldOrder(order = 22)
@Asn1Optional public SequenceOfStringIA5 includedCarriersIA5;
+ /** The excluded carriers num. */
@FieldOrder(order = 23)
@Asn1Optional public SequenceOfCarrierNum excludedCarriersNum;
+ /** The excluded carriers IA 5. */
@FieldOrder(order = 24)
@Asn1Optional public SequenceOfStringIA5 excludedCarriersIA5;
+ /** The included service brands. */
@FieldOrder(order = 25)
@Asn1Optional public SequenceOfServiceBrands includedServiceBrands;
+ /** The excluded service brands. */
@FieldOrder(order = 26)
@Asn1Optional public SequenceOfServiceBrands excludedServiceBrands;
+ /** The valid region. */
@FieldOrder(order = 27)
@Asn1Optional public SequenceOfRegionalValidityType validRegion;
+ /** The tariffs. */
@FieldOrder(order = 28)
@Asn1Optional public SequenceOfTariffType tariffs;
+ /** The price. */
@FieldOrder(order = 29)
@Asn1Optional Asn1BigInteger price;
+ /** The vat details. */
@FieldOrder(order = 30)
@Asn1Optional SequenceOfVatDetail vatDetails;
+ /** The info text. */
@FieldOrder(order = 31)
@RestrictedString(CharacterRestriction.UTF8String)
@Asn1Optional public String infoText;
+ /** The extension. */
@FieldOrder(order = 32)
@Asn1Optional public ExtensionData extension;
@@ -162,46 +204,91 @@ public class PassData extends Object {
+ /**
+ * Gets the reference num.
+ *
+ * @return the reference num
+ */
public Asn1BigInteger getReferenceNum() {
return this.referenceNum;
}
+ /**
+ * Gets the reference IA 5.
+ *
+ * @return the reference IA 5
+ */
public String getReferenceIA5() {
return this.referenceIA5;
}
+ /**
+ * Gets the product owner num.
+ *
+ * @return the product owner num
+ */
public Long getProductOwnerNum() {
return this.productOwnerNum;
}
+ /**
+ * Gets the product owner IA 5.
+ *
+ * @return the product owner IA 5
+ */
public String getProductOwnerIA5() {
return this.productOwnerIA5;
}
+ /**
+ * Gets the product id num.
+ *
+ * @return the product id num
+ */
public Long getProductIdNum() {
return this.productIdNum;
}
+ /**
+ * Gets the product id IA 5.
+ *
+ * @return the product id IA 5
+ */
public String getProductIdIA5() {
return this.productIdIA5;
}
+ /**
+ * Gets the pass type.
+ *
+ * @return the pass type
+ */
public Long getPassType() {
return this.passType;
}
+ /**
+ * Gets the pass description.
+ *
+ * @return the pass description
+ */
public String getPassDescription() {
return this.passDescription;
}
+ /**
+ * Gets the class code.
+ *
+ * @return the class code
+ */
public TravelClassType getClassCode() {
if (classCode == null){
@@ -211,267 +298,537 @@ public class PassData extends Object {
return this.classCode;
}
+ /**
+ * Gets the valid from day.
+ *
+ * @return the valid from day
+ */
public Long getValidFromDay() {
return this.validFromDay;
}
+ /**
+ * Gets the valid from time.
+ *
+ * @return the valid from time
+ */
public Long getValidFromTime() {
return this.validFromTime;
}
+ /**
+ * Gets the valid until day.
+ *
+ * @return the valid until day
+ */
public Long getValidUntilDay() {
return this.validUntilDay;
}
+ /**
+ * Gets the valid until time.
+ *
+ * @return the valid until time
+ */
public Long getValidUntilTime() {
return this.validUntilTime;
}
+ /**
+ * Gets the validity period details.
+ *
+ * @return the validity period details
+ */
public ValidityPeriodDetailType getValidityPeriodDetails() {
return this.validityPeriodDetails;
}
+ /**
+ * Gets the number of validity days.
+ *
+ * @return the number of validity days
+ */
public Long getNumberOfValidityDays() {
return this.numberOfValidityDays;
}
+ /**
+ * Gets the number of possible trips.
+ *
+ * @return the number of possible trips
+ */
public Long getNumberOfPossibleTrips() {
return this.numberOfPossibleTrips;
}
+ /**
+ * Gets the number of days of travel.
+ *
+ * @return the number of days of travel
+ */
public Long getNumberOfDaysOfTravel() {
return this.numberOfDaysOfTravel;
}
+ /**
+ * Gets the activated day.
+ *
+ * @return the activated day
+ */
public List<Long> getActivatedDay() {
return this.activatedDay;
}
+ /**
+ * Gets the countries.
+ *
+ * @return the countries
+ */
public List<Long> getCountries() {
return this.countries;
}
+ /**
+ * Gets the included carriers num.
+ *
+ * @return the included carriers num
+ */
public List<Long> getIncludedCarriersNum() {
return this.includedCarriersNum;
}
+ /**
+ * Gets the included carriers IA 5.
+ *
+ * @return the included carriers IA 5
+ */
public List<String> getIncludedCarriersIA5() {
return this.includedCarriersIA5;
}
+ /**
+ * Gets the excluded carriers num.
+ *
+ * @return the excluded carriers num
+ */
public List<Long> getExcludedCarriersNum() {
return this.excludedCarriersNum;
}
+ /**
+ * Gets the excluded carriers IA 5.
+ *
+ * @return the excluded carriers IA 5
+ */
public SequenceOfStringIA5 getExcludedCarriersIA5() {
return this.excludedCarriersIA5;
}
+ /**
+ * Gets the included service brands.
+ *
+ * @return the included service brands
+ */
public SequenceOfServiceBrands getIncludedServiceBrands() {
return this.includedServiceBrands;
}
+ /**
+ * Gets the excluded service brands.
+ *
+ * @return the excluded service brands
+ */
public SequenceOfServiceBrands getExcludedServiceBrands() {
return this.excludedServiceBrands;
}
+ /**
+ * Gets the valid region.
+ *
+ * @return the valid region
+ */
public List<RegionalValidityType> getValidRegion() {
return this.validRegion;
}
+ /**
+ * Gets the tariffs.
+ *
+ * @return the tariffs
+ */
public List<TariffType> getTariffs() {
return this.tariffs;
}
+ /**
+ * Gets the info text.
+ *
+ * @return the info text
+ */
public String getInfoText() {
return this.infoText;
}
+ /**
+ * Gets the extension.
+ *
+ * @return the extension
+ */
public ExtensionData getExtension() {
return this.extension;
}
+ /**
+ * Sets the reference num.
+ *
+ * @param referenceNum the new reference num
+ */
public void setReferenceNum(Asn1BigInteger referenceNum) {
this.referenceNum = referenceNum;
}
+ /**
+ * Sets the reference IA 5.
+ *
+ * @param referenceIA5 the new reference IA 5
+ */
public void setReferenceIA5(String referenceIA5) {
this.referenceIA5 = referenceIA5;
}
+ /**
+ * Sets the product owner num.
+ *
+ * @param productOwnerNum the new product owner num
+ */
public void setProductOwnerNum(Long productOwnerNum) {
this.productOwnerNum = productOwnerNum;
}
+ /**
+ * Sets the product owner IA 5.
+ *
+ * @param productOwnerIA5 the new product owner IA 5
+ */
public void setProductOwnerIA5(String productOwnerIA5) {
this.productOwnerIA5 = productOwnerIA5;
}
+ /**
+ * Sets the product id num.
+ *
+ * @param productIdNum the new product id num
+ */
public void setProductIdNum(Long productIdNum) {
this.productIdNum = productIdNum;
}
+ /**
+ * Sets the product id IA 5.
+ *
+ * @param productIdIA5 the new product id IA 5
+ */
public void setProductIdIA5(String productIdIA5) {
this.productIdIA5 = productIdIA5;
}
+ /**
+ * Sets the pass type.
+ *
+ * @param passType the new pass type
+ */
public void setPassType(Long passType) {
this.passType = passType;
}
+ /**
+ * Sets the pass description.
+ *
+ * @param passDescription the new pass description
+ */
public void setPassDescription(String passDescription) {
this.passDescription = passDescription;
}
+ /**
+ * Sets the class code.
+ *
+ * @param classCode the new class code
+ */
public void setClassCode(TravelClassType classCode) {
this.classCode = classCode;
}
+ /**
+ * Sets the valid from day.
+ *
+ * @param validFromDay the new valid from day
+ */
public void setValidFromDay(Long validFromDay) {
this.validFromDay = validFromDay;
}
+ /**
+ * Sets the valid from time.
+ *
+ * @param validFromTime the new valid from time
+ */
public void setValidFromTime(Long validFromTime) {
this.validFromTime = validFromTime;
}
+ /**
+ * Sets the valid until day.
+ *
+ * @param validUntilDay the new valid until day
+ */
public void setValidUntilDay(Long validUntilDay) {
this.validUntilDay = validUntilDay;
}
+ /**
+ * Sets the valid until time.
+ *
+ * @param validUntilTime the new valid until time
+ */
public void setValidUntilTime(Long validUntilTime) {
this.validUntilTime = validUntilTime;
}
+ /**
+ * Sets the validity period details.
+ *
+ * @param validityPeriodDetails the new validity period details
+ */
public void setValidityPeriodDetails(ValidityPeriodDetailType validityPeriodDetails) {
this.validityPeriodDetails = validityPeriodDetails;
}
+ /**
+ * Sets the number of validity days.
+ *
+ * @param numberOfValidityDays the new number of validity days
+ */
public void setNumberOfValidityDays(Long numberOfValidityDays) {
this.numberOfValidityDays = numberOfValidityDays;
}
+ /**
+ * Sets the number of possible trips.
+ *
+ * @param numberOfPossibleTrips the new number of possible trips
+ */
public void setNumberOfPossibleTrips(Long numberOfPossibleTrips) {
this.numberOfPossibleTrips = numberOfPossibleTrips;
}
+ /**
+ * Sets the number of days of travel.
+ *
+ * @param numberOfDaysOfTravel the new number of days of travel
+ */
public void setNumberOfDaysOfTravel(Long numberOfDaysOfTravel) {
this.numberOfDaysOfTravel = numberOfDaysOfTravel;
}
+ /**
+ * Sets the activated day.
+ *
+ * @param activatedDay the new activated day
+ */
public void setActivatedDay(SequenceOfActivatedDays activatedDay) {
this.activatedDay = activatedDay;
}
+ /**
+ * Sets the countries.
+ *
+ * @param countries the new countries
+ */
public void setCountries(SequenceOfCountries countries) {
this.countries = countries;
}
+ /**
+ * Sets the included carriers num.
+ *
+ * @param includedCarriersNum the new included carriers num
+ */
public void setIncludedCarriersNum(SequenceOfCarrierNum includedCarriersNum) {
this.includedCarriersNum = includedCarriersNum;
}
+ /**
+ * Sets the included carriers IA 5.
+ *
+ * @param includedCarriersIA5 the new included carriers IA 5
+ */
public void setIncludedCarriersIA5(SequenceOfStringIA5 includedCarriersIA5) {
this.includedCarriersIA5 = includedCarriersIA5;
}
+ /**
+ * Sets the excluded carriers num.
+ *
+ * @param excludedCarriersNum the new excluded carriers num
+ */
public void setExcludedCarriersNum(SequenceOfCarrierNum excludedCarriersNum) {
this.excludedCarriersNum = excludedCarriersNum;
}
+ /**
+ * Sets the excluded carriers IA 5.
+ *
+ * @param excludedCarriersIA5 the new excluded carriers IA 5
+ */
public void setExcludedCarriersIA5(SequenceOfStringIA5 excludedCarriersIA5) {
this.excludedCarriersIA5 = excludedCarriersIA5;
}
+ /**
+ * Sets the included service brands.
+ *
+ * @param includedServiceBrands the new included service brands
+ */
public void setIncludedServiceBrands(SequenceOfServiceBrands includedServiceBrands) {
this.includedServiceBrands = includedServiceBrands;
}
+ /**
+ * Sets the excluded service brands.
+ *
+ * @param excludedServiceBrands the new excluded service brands
+ */
public void setExcludedServiceBrands(SequenceOfServiceBrands excludedServiceBrands) {
this.excludedServiceBrands = excludedServiceBrands;
}
+ /**
+ * Sets the valid region.
+ *
+ * @param validRegion the new valid region
+ */
public void setValidRegion(SequenceOfRegionalValidityType validRegion) {
this.validRegion = validRegion;
}
+ /**
+ * Sets the tariffs.
+ *
+ * @param tariffs the new tariffs
+ */
public void setTariffs(SequenceOfTariffType tariffs) {
this.tariffs = tariffs;
}
+ /**
+ * Sets the info text.
+ *
+ * @param infoText the new info text
+ */
public void setInfoText(String infoText) {
this.infoText = infoText;
}
+ /**
+ * Sets the extension.
+ *
+ * @param extension the new extension
+ */
public void setExtension(ExtensionData extension) {
this.extension = extension;
}
+ /**
+ * Gets the price.
+ *
+ * @return the price
+ */
public Long getPrice() {
return Asn1BigInteger.toLong(price);
}
+ /**
+ * Sets the price.
+ *
+ * @param price the new price
+ */
public void setPrice(Long price) {
this.price = Asn1BigInteger.toAsn1(price);
}
+ /**
+ * Gets the vat details.
+ *
+ * @return the vat details
+ */
public SequenceOfVatDetail getVatDetails() {
return vatDetails;
}
+ /**
+ * Sets the vat details.
+ *
+ * @param vatDetails the new vat details
+ */
public void setVatDetails(SequenceOfVatDetail vatDetails) {
this.vatDetails = vatDetails;
}
+ /**
+ * Adds the vat detail.
+ *
+ * @param vatDetail the vat detail
+ */
public void addVatDetail(VatDetailType vatDetail) {
if (this.vatDetails == null) {
this.vatDetails = new SequenceOfVatDetail();
@@ -479,6 +836,13 @@ public class PassData extends Object {
this.vatDetails.add(vatDetail);
}
+ /**
+ * Sets the validity dates.
+ *
+ * @param fromDate the from date
+ * @param untilDate the until date
+ * @param issuingDate the issuing date
+ */
public void setValidityDates (Date fromDate, Date untilDate, Date issuingDate){
if (issuingDate == null || fromDate == null) return;
@@ -493,12 +857,24 @@ public class PassData extends Object {
}
+ /**
+ * Gets the valid from date.
+ *
+ * @param issuingDate the issuing date
+ * @return the valid from date
+ */
public Date getValidFromDate(Date issuingDate){
return DateTimeUtils.getDate(issuingDate, this.validFromDay, this.validFromTime);
}
+ /**
+ * Gets the valid until date.
+ *
+ * @param issuingDate the issuing date
+ * @return the valid until date
+ */
public Date getValidUntilDate(Date issuingDate){
if (issuingDate == null) return null;
@@ -516,7 +892,29 @@ public class PassData extends Object {
}
- public void setActivatedDays(Collection<Date> dates, Date issuingDate){
+
+ public void addActivatedDays(Collection<Long> days) {
+
+ if (days == null || days.isEmpty()) return;
+
+ if (this.activatedDay == null) {
+ this.activatedDay = new SequenceOfActivatedDays();
+ }
+
+ for (Long l : days) {
+ this.activatedDay.add(l);
+ }
+
+ }
+
+ /**
+ * Sets the activated days.
+ *
+ * @param dates the dates
+ * @param issuingDate the issuing date
+ * @param validFromDate the valid from date
+ */
+ public void setActivatedDays(Collection<Date> dates, Date issuingDate, Date validFromDate){
if (this.activatedDay != null) {
this.activatedDay.clear();
@@ -524,30 +922,50 @@ public class PassData extends Object {
this.activatedDay= new SequenceOfActivatedDays();
}
+ long dateDif = 0L;
+ if (validFromDate != null) {
+ dateDif = DateTimeUtils.getDateDifference(issuingDate,validFromDate);
+ }
+
if (dates != null && !dates.isEmpty()) {
for (Date day : dates) {
- this.addActivatedDay(issuingDate, day);
+ this.addActivatedDay(issuingDate, dateDif, day);
}
}
}
- public void addActivatedDay(Date issuingDate, Date day){
+ /**
+ * Adds the activated day.
+ *
+ * @param issuingDate the issuing date in UTC
+ * @param dateOffset the date offset to be added to the issuing date
+ * @param day the day to be added
+ */
+ public void addActivatedDay(Date issuingDate, long dateOffset, Date day){
+
+ Long dayDiff = DateTimeUtils.getDateDifferenceLocal(issuingDate, day);
- Long dayDiff = DateTimeUtils.getDateDifference(issuingDate, day);
+ Long vDiff = DateTimeUtils.getDateDifferenceLocal(this.getValidFromDate(issuingDate), day);
if (this.activatedDay == null) {
this.activatedDay = new SequenceOfActivatedDays();
}
if (dayDiff != null) {
- this.activatedDay.add(dayDiff);
+ this.activatedDay.add(vDiff);
}
}
+ /**
+ * Gets the activated days.
+ *
+ * @param issuingDate the issuing date
+ * @return the activated days
+ */
public Collection<Date> getActivatedDays(Date issuingDate) {
if (this.activatedDay == null) return null;
@@ -556,7 +974,7 @@ public class PassData extends Object {
for (Long diff: this.getActivatedDay()) {
- Date day = DateTimeUtils.getDate(issuingDate, diff, null);
+ Date day = DateTimeUtils.getDate(this.getValidFromDate(issuingDate), diff, null);
if (day != null) {
dates.add(day);
@@ -568,18 +986,38 @@ public class PassData extends Object {
}
+ /**
+ * Gets the valid from UTC offset.
+ *
+ * @return the valid from UTC offset
+ */
public Long getValidFromUTCOffset() {
return validFromUTCOffset;
}
+ /**
+ * Sets the valid from UTC offset.
+ *
+ * @param validFromUTCOffset the new valid from UTC offset
+ */
public void setValidFromUTCOffset(Long validFromUTCOffset) {
this.validFromUTCOffset = validFromUTCOffset;
}
+ /**
+ * Gets the valid until UTC offset.
+ *
+ * @return the valid until UTC offset
+ */
public Long getValidUntilUTCOffset() {
return validUntilUTCOffset;
}
+ /**
+ * Sets the valid until UTC offset.
+ *
+ * @param validUntilUTCOffset the new valid until UTC offset
+ */
public void setValidUntilUTCOffset(Long validUntilUTCOffset) {
this.validUntilUTCOffset = validUntilUTCOffset;
}
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/ReservationData.java b/src/org/uic/barcode/ticket/api/asn/omv1/ReservationData.java
index 73fa5aa..adc5f71 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/ReservationData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/ReservationData.java
@@ -33,6 +33,7 @@ import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/StationPassageData.java b/src/org/uic/barcode/ticket/api/asn/omv1/StationPassageData.java
index a8718d7..36dc6bf 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/StationPassageData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/StationPassageData.java
@@ -34,6 +34,7 @@ import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfUnrestrictedLong;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/TrainLinkType.java b/src/org/uic/barcode/ticket/api/asn/omv1/TrainLinkType.java
index 3eb0871..5469c2f 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/TrainLinkType.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/TrainLinkType.java
@@ -28,6 +28,7 @@ import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
public class TrainLinkType extends Object {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/ValidityPeriodType.java b/src/org/uic/barcode/ticket/api/asn/omv1/ValidityPeriodType.java
index a41fa03..5667ad9 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/ValidityPeriodType.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/ValidityPeriodType.java
@@ -26,6 +26,7 @@ import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
public class ValidityPeriodType extends Object {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/uicBarcodeV1finalDelayConfirmation1.3.asn b/src/org/uic/barcode/ticket/api/asn/omv1/uicBarcodeV1finalDelayConfirmation1.3.asn
index 24df140..fb19462 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/uicBarcodeV1finalDelayConfirmation1.3.asn
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/uicBarcodeV1finalDelayConfirmation1.3.asn
@@ -81,7 +81,7 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
-- # local date (CET): 01.01.2018 23:05
-- # -> difference in days = 0
-- #
--- # the day difference could become -1 although this can happen for localtions in America or New Zeeland only.
+-- # the day difference could become -1 although this can happen for locations in America or New Zeeland only.
-- #
-- # implementation example:
-- #
@@ -97,6 +97,7 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
-- # issuingCal.set(Calendar.MINUTE, 0);
-- # issuingCal.set(Calendar.SECOND, 0);
-- # issuingCal.set(Calendar.MILLISECOND, 0);
+-- # Date start = startCal.getTime();
-- #
-- # Calendar fromCal = Calendar.getInstance();
-- # fromCal.clear();
@@ -106,11 +107,11 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
-- # fromCal.set(Calendar.MINUTE, 0);
-- # fromCal.set(Calendar.SECOND, 0);
-- # fromCal.set(Calendar.MILLISECOND, 0);
+-- # Date end = endCal.getTime();
-- #
--- # long diff = localDate.getTime() - issuingDate.getTime();
--- # long dayDiff = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
+-- # long diff = TimeUnit.DAYS.convert(end.getTime() - start.getTime(), TimeUnit.MILLISECONDS );
-- #
--- # return new Long(dayDiff);
+-- # return new Long(diff);
-- #
-- # }
-- #
@@ -843,7 +844,7 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
productIdIA5 IA5String OPTIONAL,
-- type of the pass, code list provided by the product owner
- -- in case of Eurail:
+ -- in case of Eurail:
-- 1 = Interrail
-- 2 = Eurail
-- 3 = Eurail Global (all countries)
@@ -858,16 +859,16 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
-- number of days from issuing date
validFromDay INTEGER (-1..700) DEFAULT 0,
validFromTime INTEGER (0..1440) OPTIONAL,
- validFromUTCOffset INTEGER (-60..60) OPTIONAL, -- offset in units of 15 minutes from local time to UTC
- -- (UTC = local + offset * 15 Minutes)
+ validFromUTCOffset INTEGER (-60..60) OPTIONAL, -- offset in units of 15 minutes from local time to UTC
+ -- (UTC = local + offset * 15 Minutes)
-- end of validity (local time)
-- number of days from valid from day, 0 = valid on valid-from-date
validUntilDay INTEGER (0..370) DEFAULT 0,
validUntilTime INTEGER (0..1440) OPTIONAL,
- validUntilUTCOffset INTEGER (-60..60) OPTIONAL, -- offset in units of 15 minutes from local time to UTC
- -- (UTC = local + offset * 15 Minutes)
- -- should be omtted in case it is the same as for depature
+ validUntilUTCOffset INTEGER (-60..60) OPTIONAL, -- offset in units of 15 minutes from local time to UTC
+ -- (UTC = local + offset * 15 Minutes)
+ -- should be omitted in case it is the same as for depature
@@ -883,21 +884,21 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
-- list of activated days in case the entire ticket is not activated
-- the day is given by the number of days from the first day of validity
- -- 0 = first day of validity
+ -- 0 = first day of validity
activatedDay SEQUENCE OF INTEGER (0..370) OPTIONAL,
-- included countries, code table according to UIC leaflet 918.9
- countries SEQUENCE OF INTEGER (1..250) OPTIONAL,
+ countries SEQUENCE OF INTEGER (1..250) OPTIONAL,
-- included carriers (RICS codes)
- includedCarrierNum SEQUENCE OF INTEGER (1..32000) OPTIONAL,
- includedCarrierIA5 SEQUENCE OF IA5String OPTIONAL,
+ includedCarrierNum SEQUENCE OF INTEGER (1..32000) OPTIONAL,
+ includedCarrierIA5 SEQUENCE OF IA5String OPTIONAL,
-- excluded carriers (RICS codes)
- excludedCarrierNum SEQUENCE OF INTEGER (1..32000) OPTIONAL,
- excludedCarrierIA5 SEQUENCE OF IA5String OPTIONAL,
+ excludedCarrierNum SEQUENCE OF INTEGER (1..32000) OPTIONAL,
+ excludedCarrierIA5 SEQUENCE OF IA5String OPTIONAL,
- -- service brand: code list https://uic.org/service-brand-code-list
+ -- service brand: code list https://uic.org/service-brand-code-list
includedServiceBrands SEQUENCE OF INTEGER (1..32000) OPTIONAL,
excludedServiceBrands SEQUENCE OF INTEGER (1..32000) OPTIONAL,
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java b/src/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java
index 9bab332..6b2beb4 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java
@@ -34,6 +34,7 @@ import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCarrierNum;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/CountermarkData.java b/src/org/uic/barcode/ticket/api/asn/omv2/CountermarkData.java
index 41c73b5..435c6ef 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/CountermarkData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/CountermarkData.java
@@ -32,6 +32,7 @@ import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/DateTimeUtils.java b/src/org/uic/barcode/ticket/api/asn/omv2/DateTimeUtils.java
deleted file mode 100644
index 04b1c2e..0000000
--- a/src/org/uic/barcode/ticket/api/asn/omv2/DateTimeUtils.java
+++ /dev/null
@@ -1,198 +0,0 @@
-package org.uic.barcode.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();
-
- }
-
-
-}
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/FIPTicketData.java b/src/org/uic/barcode/ticket/api/asn/omv2/FIPTicketData.java
index e11a66f..dbf35e2 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/FIPTicketData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/FIPTicketData.java
@@ -32,6 +32,8 @@ import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfActivatedDays;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
public class FIPTicketData extends Object {
public FIPTicketData() {
@@ -275,20 +277,16 @@ public class FIPTicketData extends Object {
}
- public void setActivatedDays(Collection<Date> dates, Date issuingDate){
+ public void addActivatedDays(Collection<Long> days) {
- if (this.activatedDay != null) {
- this.activatedDay.clear();
- } else {
- this.activatedDay= new SequenceOfActivatedDays();
+ if (days == null || days.isEmpty()) return;
+
+ if (this.activatedDay == null) {
+ this.activatedDay = new SequenceOfActivatedDays();
}
- if (dates != null && !dates.isEmpty()) {
-
- for (Date day : dates) {
- this.addActivatedDay(issuingDate, day);
- }
-
+ for (Long l : days) {
+ this.activatedDay.add(l);
}
}
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java b/src/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java
index dc43d75..cef0b02 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java
@@ -31,6 +31,7 @@ import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
public class IncludedOpenTicketType extends Object {
public IncludedOpenTicketType() {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java b/src/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java
index 402323e..c0dac70 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java
@@ -35,6 +35,8 @@ import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfActivatedDays;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
@@ -601,21 +603,16 @@ public class OpenTicketData extends Object {
}
-
- public void setActivatedDays(Collection<Date> dates, Date issuingDate){
+ public void addActivatedDays(Collection<Long> days) {
+
+ if (days == null || days.isEmpty()) return;
- if (this.activatedDay != null) {
- this.activatedDay.clear();
- } else {
- this.activatedDay= new SequenceOfActivatedDays();
+ if (this.activatedDay == null) {
+ this.activatedDay = new SequenceOfActivatedDays();
}
- if (dates != null && !dates.isEmpty()) {
-
- for (Date day : dates) {
- this.addActivatedDay(issuingDate, day);
- }
-
+ for (Long l : days) {
+ this.activatedDay.add(l);
}
}
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java b/src/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java
index 1e14394..4f6f6d8 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/ParkingGroundData.java
@@ -30,6 +30,7 @@ import org.uic.barcode.asn1.datatypes.HasExtensionMarker;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/PassData.java b/src/org/uic/barcode/ticket/api/asn/omv2/PassData.java
index b3b02e7..b5c8429 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/PassData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/PassData.java
@@ -34,6 +34,8 @@ import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfActivatedDays;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
@@ -516,20 +518,16 @@ public class PassData extends Object {
}
- public void setActivatedDays(Collection<Date> dates, Date issuingDate){
+ public void addActivatedDays(Collection<Long> days) {
- if (this.activatedDay != null) {
- this.activatedDay.clear();
- } else {
- this.activatedDay= new SequenceOfActivatedDays();
+ if (days == null || days.isEmpty()) return;
+
+ if (this.activatedDay == null) {
+ this.activatedDay = new SequenceOfActivatedDays();
}
- if (dates != null && !dates.isEmpty()) {
-
- for (Date day : dates) {
- this.addActivatedDay(issuingDate, day);
- }
-
+ for (Long l : days) {
+ this.activatedDay.add(l);
}
}
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java b/src/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java
index a474e7d..31b3fa8 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java
@@ -33,6 +33,7 @@ import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/StationPassageData.java b/src/org/uic/barcode/ticket/api/asn/omv2/StationPassageData.java
index 6c6d36d..a378bb7 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/StationPassageData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/StationPassageData.java
@@ -34,6 +34,7 @@ import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfUnrestrictedLong;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
@HasExtensionMarker
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java b/src/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java
index 7c3de46..f269497 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java
@@ -28,6 +28,7 @@ import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
public class TrainLinkType extends Object {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java b/src/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java
index 6c36c97..7b08f73 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java
@@ -26,6 +26,7 @@ import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
public class ValidityPeriodType extends Object {
diff --git a/src/org/uic/barcode/ticket/api/asn/omv2/uicBarcodeFCBv2.0.asn b/src/org/uic/barcode/ticket/api/asn/omv2/uicBarcodeFCBv2.0.asn
index b67ac06..2c2eda7 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv2/uicBarcodeFCBv2.0.asn
+++ b/src/org/uic/barcode/ticket/api/asn/omv2/uicBarcodeFCBv2.0.asn
@@ -535,7 +535,7 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
vatDetail SEQUENCE OF VatDetailType OPTIONAL,
- -- type of supplement - code list from 018.1
+ -- type of supplement - code list from 918.1
typeOfSupplement INTEGER (0..9) DEFAULT 0,
numberOfSupplements INTEGER (0..200) DEFAULT 0,
diff --git a/src/org/uic/barcode/ticket/api/test/DateTimeUtilsTest.java b/src/org/uic/barcode/ticket/api/test/DateTimeUtilsTest.java
index 5435c6b..5b2e578 100644
--- a/src/org/uic/barcode/ticket/api/test/DateTimeUtilsTest.java
+++ b/src/org/uic/barcode/ticket/api/test/DateTimeUtilsTest.java
@@ -3,7 +3,7 @@ package org.uic.barcode.ticket.api.test;
import java.util.Calendar;
import java.util.TimeZone;
import org.junit.Test;
-import org.uic.barcode.ticket.api.asn.omv1.DateTimeUtils;
+import org.uic.barcode.ticket.api.utils.DateTimeUtils;
public class DateTimeUtilsTest{
diff --git a/src/org/uic/barcode/ticket/api/test/PassTestTicketV1.java b/src/org/uic/barcode/ticket/api/test/PassTestTicketV1.java
new file mode 100644
index 0000000..80a337c
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/PassTestTicketV1.java
@@ -0,0 +1,150 @@
+package org.uic.barcode.ticket.api.test;
+
+import org.uic.barcode.ticket.api.asn.omv1.CardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv1.ControlData;
+import org.uic.barcode.ticket.api.asn.omv1.CustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv1.DocumentData;
+import org.uic.barcode.ticket.api.asn.omv1.ExtensionData;
+import org.uic.barcode.ticket.api.asn.omv1.IssuingData;
+import org.uic.barcode.ticket.api.asn.omv1.LinkMode;
+import org.uic.barcode.ticket.api.asn.omv1.PassData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfDocumentData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfExtensionData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv1.TicketDetailData;
+import org.uic.barcode.ticket.api.asn.omv1.TicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv1.TicketType;
+import org.uic.barcode.ticket.api.asn.omv1.TravelClassType;
+import org.uic.barcode.ticket.api.asn.omv1.TravelerData;
+import org.uic.barcode.ticket.api.asn.omv1.TravelerType;
+import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
+
+ public class PassTestTicketV1 {
+
+ public static UicRailTicketData getUicTestTicket() {
+ UicRailTicketData ticket = new UicRailTicketData();
+ populateTicket(ticket);
+ return ticket;
+ }
+
+
+ private static void populateTicket(UicRailTicketData ticket) {
+
+ ticket.setControlDetail(new ControlData());
+ populate(ticket.getControlDetail());
+
+
+ ticket.setIssuingDetail(new IssuingData());
+ populateIssuingData(ticket.getIssuingDetail());
+
+ TravelerData td = new TravelerData();
+ populateTravelerData(td);
+ ticket.setTravelerDetail(td);
+
+ SequenceOfDocumentData ds = new SequenceOfDocumentData();
+
+
+ //OpenTicket
+ DocumentData do1 = new DocumentData();
+ addPass(do1);
+ ds.add(do1);
+
+ ticket.setTransportDocument(ds);
+
+ SequenceOfExtensionData ed = new SequenceOfExtensionData();
+ populateExtensionSequence(ed);
+ ticket.setExtension(ed);
+
+ }
+
+
+ private static void addPass(DocumentData dd) {
+
+ TicketDetailData tdd = new TicketDetailData();
+ PassData otd = new PassData();
+ otd.setInfoText("pass");
+ otd.setClassCode(TravelClassType.first);
+ otd.setPassDescription("ONE COUNTRY");
+ tdd.setPass(otd);
+ dd.setTicket(tdd);
+ }
+
+
+ private static void populateTravelerData(TravelerData td) {
+ td.setGroupName("myGroup");
+ SequenceOfTravelerType trs = new SequenceOfTravelerType();
+ TravelerType tr = new TravelerType();
+ tr.setIdCard("12345");
+ tr.setFirstName("John");
+ tr.setSecondName("Dow");
+ tr.setTicketHolder(true);
+ SequenceOfCustomerStatusType ts = new SequenceOfCustomerStatusType();
+ CustomerStatusType cst = new CustomerStatusType();
+ cst.setCustomerStatusDescr("senior");
+ ts.add(cst);
+ tr.setStatus(ts);
+ trs.add(tr);
+ td.setTraveler(trs);
+ }
+
+ private static void populateIssuingData(IssuingData issuingDetail) {
+ issuingDetail.setIssuingYear(2018L);
+ issuingDetail.setIssuingDay(1L);
+ issuingDetail.setIssuerPNR("issuerTestPNR");
+ issuingDetail.setSpecimen(true);
+ issuingDetail.setSecurePaperTicket(false);
+ issuingDetail.setActivated(true);
+ issuingDetail.setIssuedOnLine(12L);
+ }
+
+ private static void populateExtensionSequence(SequenceOfExtensionData ed) {
+ ExtensionData ed1 = new ExtensionData();
+ ed1.setExtensionId("1");
+ byte[] ba1 = { (byte) 0x82, (byte) 0xDA };
+ ed1.setExtensionData(ba1);
+ ExtensionData ed2 = new ExtensionData();
+ ed2.setExtensionId("2");
+ byte[] ba2 = { (byte) 0x83, (byte) 0xDA };
+ ed2.setExtensionData(ba2);
+ ed.add(ed1);
+ ed.add(ed2);
+ }
+
+ private static void populate(ControlData controlDetail) {
+ controlDetail.infoText = "cd";
+ controlDetail.setAgeCheckRequired(false);
+ controlDetail.setIdentificationByIdCard(false);
+ controlDetail.setIdentificationByPassportId(false);
+ controlDetail.setOnlineValidationRequired(false);
+ controlDetail.setPassportValidationRequired(false);
+ controlDetail.setReductionCardCheckRequired(false);
+ controlDetail.setIdentificationByCardReference(new SequenceOfCardReferenceType());
+ controlDetail.getIdentificationByCardReference().add(populateCardRefrence());
+ SequenceOfTicketLinkType sit = new SequenceOfTicketLinkType();
+ populateLinkedTickets(sit);
+ controlDetail.setIncludedTickets(sit);
+ }
+
+ private static void populateLinkedTickets(SequenceOfTicketLinkType sequenceOfTicketLinkType) {
+ TicketLinkType tlt = new TicketLinkType();
+ tlt.productOwnerIA5="test";
+ tlt.setTicketType(TicketType.pass);
+ tlt.setIssuerPNR("PNR");
+ tlt.setReferenceIA5("UED12435867");
+ tlt.setLinkMode(LinkMode.onlyValidInCombination);
+ tlt.setIssuerName("OEBB");
+ sequenceOfTicketLinkType.add(tlt);
+ }
+
+ private static CardReferenceType populateCardRefrence() {
+ CardReferenceType cr = new CardReferenceType();
+ cr.setTrailingCardIdNum(100L);
+ return cr;
+ }
+
+
+
+ }
diff --git a/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestTicketCase1V1.java b/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestTicketCase1V1.java
new file mode 100644
index 0000000..b037440
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestTicketCase1V1.java
@@ -0,0 +1,170 @@
+package org.uic.barcode.ticket.api.test;
+
+import org.uic.barcode.ticket.api.asn.omv1.CardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv1.ControlData;
+import org.uic.barcode.ticket.api.asn.omv1.CustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv1.DocumentData;
+import org.uic.barcode.ticket.api.asn.omv1.ExtensionData;
+import org.uic.barcode.ticket.api.asn.omv1.IssuingData;
+import org.uic.barcode.ticket.api.asn.omv1.LinkMode;
+import org.uic.barcode.ticket.api.asn.omv1.PassData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfActivatedDays;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfDocumentData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfExtensionData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv1.TicketDetailData;
+import org.uic.barcode.ticket.api.asn.omv1.TicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv1.TicketType;
+import org.uic.barcode.ticket.api.asn.omv1.TravelClassType;
+import org.uic.barcode.ticket.api.asn.omv1.TravelerData;
+import org.uic.barcode.ticket.api.asn.omv1.TravelerType;
+import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
+
+ public class PassTimeZoneTestTicketCase1V1 {
+
+ public static UicRailTicketData getUicTestTicket() {
+ UicRailTicketData ticket = new UicRailTicketData();
+ populateTicket(ticket);
+ return ticket;
+ }
+
+
+
+ private static void populateTicket(UicRailTicketData ticket) {
+
+ ticket.setControlDetail(new ControlData());
+ populate(ticket.getControlDetail());
+
+
+ ticket.setIssuingDetail(new IssuingData());
+ populateIssuingData(ticket.getIssuingDetail());
+
+ TravelerData td = new TravelerData();
+ populateTravelerData(td);
+ ticket.setTravelerDetail(td);
+
+ SequenceOfDocumentData ds = new SequenceOfDocumentData();
+
+
+ //OpenTicket
+ DocumentData do1 = new DocumentData();
+ addPass1(do1);
+ ds.add(do1);
+
+
+ ticket.setTransportDocument(ds);
+
+ SequenceOfExtensionData ed = new SequenceOfExtensionData();
+ populateExtensionSequence(ed);
+ ticket.setExtension(ed);
+
+ }
+
+
+ //issue date: 04-03-2021 12:30 UTC
+ private static void populateIssuingData(IssuingData issuingDetail) {
+ issuingDetail.setIssuingYear(2021L);
+ issuingDetail.setIssuingTime(750L);
+ issuingDetail.setIssuingDay(63L);
+ issuingDetail.setIssuerPNR("issuerTestPNR");
+ issuingDetail.setSpecimen(true);
+ issuingDetail.setSecurePaperTicket(false);
+ issuingDetail.setActivated(true);
+ issuingDetail.setIssuedOnLine(12L);
+ }
+
+ private static void addPass1(DocumentData dd) {
+
+ TicketDetailData tdd = new TicketDetailData();
+ PassData otd = new PassData();
+ otd.setInfoText("pass");
+ otd.setClassCode(TravelClassType.first);
+ otd.setPassDescription("ONE COUNTRY");
+ otd.setValidFromDay(10L);
+ otd.setValidFromTime(0L);
+ otd.setValidFromUTCOffset(0L);
+ otd.setValidUntilDay(11L);
+ otd.setValidUntilTime(0L);
+ otd.setValidUntilUTCOffset(0L);
+ SequenceOfActivatedDays s = new SequenceOfActivatedDays();
+ otd.setActivatedDay(s);
+ s.add(0L);
+
+ tdd.setPass(otd);
+ dd.setTicket(tdd);
+ }
+
+
+
+ private static void populateTravelerData(TravelerData td) {
+ td.setGroupName("myGroup");
+ SequenceOfTravelerType trs = new SequenceOfTravelerType();
+ TravelerType tr = new TravelerType();
+ tr.setIdCard("12345");
+ tr.setFirstName("John");
+ tr.setSecondName("Dow");
+ tr.setTicketHolder(true);
+ SequenceOfCustomerStatusType ts = new SequenceOfCustomerStatusType();
+ CustomerStatusType cst = new CustomerStatusType();
+ cst.setCustomerStatusDescr("senior");
+ ts.add(cst);
+ tr.setStatus(ts);
+ trs.add(tr);
+ td.setTraveler(trs);
+ }
+
+
+
+
+
+ private static void populateExtensionSequence(SequenceOfExtensionData ed) {
+ ExtensionData ed1 = new ExtensionData();
+ ed1.setExtensionId("1");
+ byte[] ba1 = { (byte) 0x82, (byte) 0xDA };
+ ed1.setExtensionData(ba1);
+ ExtensionData ed2 = new ExtensionData();
+ ed2.setExtensionId("2");
+ byte[] ba2 = { (byte) 0x83, (byte) 0xDA };
+ ed2.setExtensionData(ba2);
+ ed.add(ed1);
+ ed.add(ed2);
+ }
+
+ private static void populate(ControlData controlDetail) {
+ controlDetail.infoText = "cd";
+ controlDetail.setAgeCheckRequired(false);
+ controlDetail.setIdentificationByIdCard(false);
+ controlDetail.setIdentificationByPassportId(false);
+ controlDetail.setOnlineValidationRequired(false);
+ controlDetail.setPassportValidationRequired(false);
+ controlDetail.setReductionCardCheckRequired(false);
+ controlDetail.setIdentificationByCardReference(new SequenceOfCardReferenceType());
+ controlDetail.getIdentificationByCardReference().add(populateCardRefrence());
+ SequenceOfTicketLinkType sit = new SequenceOfTicketLinkType();
+ populateLinkedTickets(sit);
+ controlDetail.setIncludedTickets(sit);
+ }
+
+ private static void populateLinkedTickets(SequenceOfTicketLinkType sequenceOfTicketLinkType) {
+ TicketLinkType tlt = new TicketLinkType();
+ tlt.productOwnerIA5="test";
+ tlt.setTicketType(TicketType.pass);
+ tlt.setIssuerPNR("PNR");
+ tlt.setReferenceIA5("UED12435867");
+ tlt.setLinkMode(LinkMode.onlyValidInCombination);
+ tlt.setIssuerName("OEBB");
+ sequenceOfTicketLinkType.add(tlt);
+ }
+
+ private static CardReferenceType populateCardRefrence() {
+ CardReferenceType cr = new CardReferenceType();
+ cr.setTrailingCardIdNum(100L);
+ return cr;
+ }
+
+
+
+ }
diff --git a/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestTicketCase2V1.java b/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestTicketCase2V1.java
new file mode 100644
index 0000000..69db492
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestTicketCase2V1.java
@@ -0,0 +1,167 @@
+package org.uic.barcode.ticket.api.test;
+
+import org.uic.barcode.ticket.api.asn.omv1.CardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv1.ControlData;
+import org.uic.barcode.ticket.api.asn.omv1.CustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv1.DocumentData;
+import org.uic.barcode.ticket.api.asn.omv1.ExtensionData;
+import org.uic.barcode.ticket.api.asn.omv1.IssuingData;
+import org.uic.barcode.ticket.api.asn.omv1.LinkMode;
+import org.uic.barcode.ticket.api.asn.omv1.PassData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfActivatedDays;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfDocumentData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfExtensionData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv1.TicketDetailData;
+import org.uic.barcode.ticket.api.asn.omv1.TicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv1.TicketType;
+import org.uic.barcode.ticket.api.asn.omv1.TravelClassType;
+import org.uic.barcode.ticket.api.asn.omv1.TravelerData;
+import org.uic.barcode.ticket.api.asn.omv1.TravelerType;
+import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
+
+ public class PassTimeZoneTestTicketCase2V1 {
+
+ public static UicRailTicketData getUicTestTicket() {
+ UicRailTicketData ticket = new UicRailTicketData();
+ populateTicket(ticket);
+ return ticket;
+ }
+
+
+
+ private static void populateTicket(UicRailTicketData ticket) {
+
+ ticket.setControlDetail(new ControlData());
+ populate(ticket.getControlDetail());
+
+
+ ticket.setIssuingDetail(new IssuingData());
+ populateIssuingData(ticket.getIssuingDetail());
+
+ TravelerData td = new TravelerData();
+ populateTravelerData(td);
+ ticket.setTravelerDetail(td);
+
+ SequenceOfDocumentData ds = new SequenceOfDocumentData();
+
+
+ //OpenTicket
+ DocumentData do1 = new DocumentData();
+ addPass1(do1);
+
+ ds.add(do1);
+
+
+ ticket.setTransportDocument(ds);
+
+ SequenceOfExtensionData ed = new SequenceOfExtensionData();
+ populateExtensionSequence(ed);
+ ticket.setExtension(ed);
+
+ }
+
+
+ //issue date: 04-03-2021 00:30 UTC
+ private static void populateIssuingData(IssuingData issuingDetail) {
+ issuingDetail.setIssuingYear(2021L);
+ issuingDetail.setIssuingTime(30L);
+ issuingDetail.setIssuingDay(63L);
+ issuingDetail.setIssuerPNR("issuerTestPNR");
+ issuingDetail.setSpecimen(true);
+ issuingDetail.setSecurePaperTicket(false);
+ issuingDetail.setActivated(true);
+ issuingDetail.setIssuedOnLine(12L);
+ }
+
+ private static void addPass1(DocumentData dd) {
+
+ TicketDetailData tdd = new TicketDetailData();
+ PassData otd = new PassData();
+ otd.setInfoText("pass");
+ otd.setClassCode(TravelClassType.first);
+ otd.setPassDescription("ONE COUNTRY");
+ otd.setValidFromDay(10L);
+ otd.setValidFromTime(0L);
+ otd.setValidFromUTCOffset(0L);
+ otd.setValidUntilDay(11L);
+ otd.setValidUntilTime(0L);
+ otd.setValidUntilUTCOffset(0L);
+ SequenceOfActivatedDays s = new SequenceOfActivatedDays();
+ otd.setActivatedDay(s);
+ s.add(0L);
+
+ tdd.setPass(otd);
+ dd.setTicket(tdd);
+ }
+
+
+ private static void populateTravelerData(TravelerData td) {
+ td.setGroupName("myGroup");
+ SequenceOfTravelerType trs = new SequenceOfTravelerType();
+ TravelerType tr = new TravelerType();
+ tr.setIdCard("12345");
+ tr.setFirstName("John");
+ tr.setSecondName("Dow");
+ tr.setTicketHolder(true);
+ SequenceOfCustomerStatusType ts = new SequenceOfCustomerStatusType();
+ CustomerStatusType cst = new CustomerStatusType();
+ cst.setCustomerStatusDescr("senior");
+ ts.add(cst);
+ tr.setStatus(ts);
+ trs.add(tr);
+ td.setTraveler(trs);
+ }
+
+
+ private static void populateExtensionSequence(SequenceOfExtensionData ed) {
+ ExtensionData ed1 = new ExtensionData();
+ ed1.setExtensionId("1");
+ byte[] ba1 = { (byte) 0x82, (byte) 0xDA };
+ ed1.setExtensionData(ba1);
+ ExtensionData ed2 = new ExtensionData();
+ ed2.setExtensionId("2");
+ byte[] ba2 = { (byte) 0x83, (byte) 0xDA };
+ ed2.setExtensionData(ba2);
+ ed.add(ed1);
+ ed.add(ed2);
+ }
+
+ private static void populate(ControlData controlDetail) {
+ controlDetail.infoText = "cd";
+ controlDetail.setAgeCheckRequired(false);
+ controlDetail.setIdentificationByIdCard(false);
+ controlDetail.setIdentificationByPassportId(false);
+ controlDetail.setOnlineValidationRequired(false);
+ controlDetail.setPassportValidationRequired(false);
+ controlDetail.setReductionCardCheckRequired(false);
+ controlDetail.setIdentificationByCardReference(new SequenceOfCardReferenceType());
+ controlDetail.getIdentificationByCardReference().add(populateCardRefrence());
+ SequenceOfTicketLinkType sit = new SequenceOfTicketLinkType();
+ populateLinkedTickets(sit);
+ controlDetail.setIncludedTickets(sit);
+ }
+
+ private static void populateLinkedTickets(SequenceOfTicketLinkType sequenceOfTicketLinkType) {
+ TicketLinkType tlt = new TicketLinkType();
+ tlt.productOwnerIA5="test";
+ tlt.setTicketType(TicketType.pass);
+ tlt.setIssuerPNR("PNR");
+ tlt.setReferenceIA5("UED12435867");
+ tlt.setLinkMode(LinkMode.onlyValidInCombination);
+ tlt.setIssuerName("OEBB");
+ sequenceOfTicketLinkType.add(tlt);
+ }
+
+ private static CardReferenceType populateCardRefrence() {
+ CardReferenceType cr = new CardReferenceType();
+ cr.setTrailingCardIdNum(100L);
+ return cr;
+ }
+
+
+
+ }
diff --git a/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestTicketCase3V1.java b/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestTicketCase3V1.java
new file mode 100644
index 0000000..8323baa
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestTicketCase3V1.java
@@ -0,0 +1,206 @@
+package org.uic.barcode.ticket.api.test;
+
+import org.uic.barcode.ticket.api.asn.omv1.CardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv1.ControlData;
+import org.uic.barcode.ticket.api.asn.omv1.CustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv1.DocumentData;
+import org.uic.barcode.ticket.api.asn.omv1.ExtensionData;
+import org.uic.barcode.ticket.api.asn.omv1.IssuingData;
+import org.uic.barcode.ticket.api.asn.omv1.LinkMode;
+import org.uic.barcode.ticket.api.asn.omv1.PassData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfActivatedDays;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfDocumentData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfExtensionData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv1.TicketDetailData;
+import org.uic.barcode.ticket.api.asn.omv1.TicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv1.TicketType;
+import org.uic.barcode.ticket.api.asn.omv1.TravelClassType;
+import org.uic.barcode.ticket.api.asn.omv1.TravelerData;
+import org.uic.barcode.ticket.api.asn.omv1.TravelerType;
+import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
+
+ public class PassTimeZoneTestTicketCase3V1 {
+
+ public static UicRailTicketData getUicTestTicket() {
+ UicRailTicketData ticket = new UicRailTicketData();
+ populateTicket(ticket);
+ return ticket;
+ }
+
+ /*
+ *
+ * Case 1:
+ issue date: 04-03-2021 12:30 UTC
+ issuingYear: 2021
+ issuingDay: 63
+ issuingTime: 750
+ validFromDay: 10
+ activatedDays: [0]
+ utcOffset: 0
+
+ expected: activated for 04-03-2021 + 10 + 0 00:00 UTC --> 14-03-2021
+
+ Case 2:
+ issue date: 04-03-2021 00:30 UTC
+ issuingYear: 2021
+ issuingDay: 63
+ issuingTime: 30
+ validFromDay: 10
+ activatedDays: [0]
+ utcOffset: 0
+
+ expected: activated for 04-03-2021 + 10 + 0 00:00 UTC --> 14-03-2021
+
+ Case 3:
+ issue date: 03-03-2021 23:30 UTC
+ issuingYear: 2021
+ issuingDay: 62
+ issuingTime: 1410
+ validFromDay: 11
+ activatedDays: [0]
+
+ expected: activated for 03-03-2021 + 11 + 0 00:00 UTC --> 14-03-2021
+
+
+ */
+
+
+
+ private static void populateTicket(UicRailTicketData ticket) {
+
+ ticket.setControlDetail(new ControlData());
+ populate(ticket.getControlDetail());
+
+
+ ticket.setIssuingDetail(new IssuingData());
+ populateIssuingData(ticket.getIssuingDetail());
+
+ TravelerData td = new TravelerData();
+ populateTravelerData(td);
+ ticket.setTravelerDetail(td);
+
+ SequenceOfDocumentData ds = new SequenceOfDocumentData();
+
+
+ //OpenTicket
+ DocumentData do1 = new DocumentData();
+ addPass1(do1);
+ ds.add(do1);
+
+
+ ticket.setTransportDocument(ds);
+
+ SequenceOfExtensionData ed = new SequenceOfExtensionData();
+ populateExtensionSequence(ed);
+ ticket.setExtension(ed);
+
+ }
+
+
+ //03-03-2021 23:30 UTC
+ private static void populateIssuingData(IssuingData issuingDetail) {
+ issuingDetail.setIssuingYear(2021L);
+ issuingDetail.setIssuingTime(1410L);
+ issuingDetail.setIssuingDay(62L);
+ issuingDetail.setIssuerPNR("issuerTestPNR");
+ issuingDetail.setSpecimen(true);
+ issuingDetail.setSecurePaperTicket(false);
+ issuingDetail.setActivated(true);
+ issuingDetail.setIssuedOnLine(12L);
+ }
+
+ private static void addPass1(DocumentData dd) {
+
+ TicketDetailData tdd = new TicketDetailData();
+ PassData otd = new PassData();
+ otd.setInfoText("pass");
+ otd.setClassCode(TravelClassType.first);
+ otd.setPassDescription("ONE COUNTRY");
+ otd.setValidFromDay(11L);
+ otd.setValidFromTime(0L);
+ otd.setValidFromUTCOffset(0L);
+ otd.setValidUntilDay(12L);
+ otd.setValidUntilTime(0L);
+ otd.setValidUntilUTCOffset(0L);
+ SequenceOfActivatedDays s = new SequenceOfActivatedDays();
+ otd.setActivatedDay(s);
+ s.add(0L);
+
+ tdd.setPass(otd);
+ dd.setTicket(tdd);
+ }
+
+
+ private static void populateTravelerData(TravelerData td) {
+ td.setGroupName("myGroup");
+ SequenceOfTravelerType trs = new SequenceOfTravelerType();
+ TravelerType tr = new TravelerType();
+ tr.setIdCard("12345");
+ tr.setFirstName("John");
+ tr.setSecondName("Dow");
+ tr.setTicketHolder(true);
+ SequenceOfCustomerStatusType ts = new SequenceOfCustomerStatusType();
+ CustomerStatusType cst = new CustomerStatusType();
+ cst.setCustomerStatusDescr("senior");
+ ts.add(cst);
+ tr.setStatus(ts);
+ trs.add(tr);
+ td.setTraveler(trs);
+ }
+
+
+
+
+
+ private static void populateExtensionSequence(SequenceOfExtensionData ed) {
+ ExtensionData ed1 = new ExtensionData();
+ ed1.setExtensionId("1");
+ byte[] ba1 = { (byte) 0x82, (byte) 0xDA };
+ ed1.setExtensionData(ba1);
+ ExtensionData ed2 = new ExtensionData();
+ ed2.setExtensionId("2");
+ byte[] ba2 = { (byte) 0x83, (byte) 0xDA };
+ ed2.setExtensionData(ba2);
+ ed.add(ed1);
+ ed.add(ed2);
+ }
+
+ private static void populate(ControlData controlDetail) {
+ controlDetail.infoText = "cd";
+ controlDetail.setAgeCheckRequired(false);
+ controlDetail.setIdentificationByIdCard(false);
+ controlDetail.setIdentificationByPassportId(false);
+ controlDetail.setOnlineValidationRequired(false);
+ controlDetail.setPassportValidationRequired(false);
+ controlDetail.setReductionCardCheckRequired(false);
+ controlDetail.setIdentificationByCardReference(new SequenceOfCardReferenceType());
+ controlDetail.getIdentificationByCardReference().add(populateCardRefrence());
+ SequenceOfTicketLinkType sit = new SequenceOfTicketLinkType();
+ populateLinkedTickets(sit);
+ controlDetail.setIncludedTickets(sit);
+ }
+
+ private static void populateLinkedTickets(SequenceOfTicketLinkType sequenceOfTicketLinkType) {
+ TicketLinkType tlt = new TicketLinkType();
+ tlt.productOwnerIA5="test";
+ tlt.setTicketType(TicketType.pass);
+ tlt.setIssuerPNR("PNR");
+ tlt.setReferenceIA5("UED12435867");
+ tlt.setLinkMode(LinkMode.onlyValidInCombination);
+ tlt.setIssuerName("OEBB");
+ sequenceOfTicketLinkType.add(tlt);
+ }
+
+ private static CardReferenceType populateCardRefrence() {
+ CardReferenceType cr = new CardReferenceType();
+ cr.setTrailingCardIdNum(100L);
+ return cr;
+ }
+
+
+
+ }
diff --git a/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestV1.java b/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestV1.java
new file mode 100644
index 0000000..1c0553f
--- /dev/null
+++ b/src/org/uic/barcode/ticket/api/test/PassTimeZoneTestV1.java
@@ -0,0 +1,419 @@
+package org.uic.barcode.ticket.api.test;
+
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IPass;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoder;
+
+
+/**
+ * The Class PassTimeZoneTestV1.
+ *
+ *
+ * test validity dates and activated days in different time zones
+ *
+ Case 1:
+ issue date: 04-03-2021 12:30 UTC
+ issuingYear: 2021
+ issuingDay: 63
+ issuingTime: 750
+ validFromDay: 10
+ activatedDays: [0]
+ utcOffset: 0
+
+ expected: activated for 04-03-2021 + 10 + 0 00:00 UTC --> 14-03-2021
+
+ Case 2:
+ issue date: 04-03-2021 00:30 UTC
+ issuingYear: 2021
+ issuingDay: 63
+ issuingTime: 30
+ validFromDay: 10
+ activatedDays: [0]
+ utcOffset: 0
+
+ expected: activated for 04-03-2021 + 10 + 0 00:00 UTC --> 14-03-2021
+
+ Case 3:
+ issue date: 03-03-2021 23:30 UTC
+ issuingYear: 2021
+ issuingDay: 62
+ issuingTime: 1410
+ validFromDay: 11
+ activatedDays: [0]
+
+ expected: activated for 03-03-2021 + 11 + 0 00:00 UTC --> 14-03-2021
+ *
+ * - Test tickets defined on the level of the asn.1 object model
+ * - set the local time zone
+ * - decoded to get an API ticket object
+ * - encode again to
+ *
+ *
+ *
+ *
+ */
+public class PassTimeZoneTestV1 {
+
+ /** The low level encoded test ticket test case 1 . */
+ private byte[] encoded1 = null;
+
+ /** The low level encoded test ticket test case 2 . */
+ private byte[] encoded2 = null;
+
+ /** The low level encoded test ticket test case 3 . */
+ private byte[] encoded3 = null;
+
+ /** The decoder. */
+ OpenAsn2ApiDecoder decoder = new OpenAsn2ApiDecoder();
+
+ /** The encoder. */
+ Api2OpenAsnEncoder encoder = new Api2OpenAsnEncoder();
+
+ /** The API ticket low level encoded for case 1. */
+ IUicRailTicket iTicketDecodedFromAsn1Case1 = null;
+
+ /** The API ticket low level encoded for case 2. */
+ IUicRailTicket iTicketDecodedFromAsn1Case2 = null;
+
+ /** The API ticket low level encoded for case 3. */
+ IUicRailTicket iTicketDecodedFromAsn1Case3 = null;
+
+
+ /** The ticket decoded 1. */
+ IUicRailTicket iTicketDecodedCase1 = null;
+
+ /** The i ticket decoded 2. */
+ IUicRailTicket iTicketDecodedCase2 = null;
+
+ /** The i ticket decoded 3. */
+ IUicRailTicket iTicketDecodedCase3 = null;
+
+ byte[] encodedInTimeZone1 = null;
+ byte[] encodedInTimeZone2 = null;
+ byte[] encodedInTimeZone3 = null;
+
+ String issuingDate1 = null;
+ String issuingDate2 = null;
+ String issuingDate3 = null;
+
+ String validFrom1 = null;
+ String validFrom2 = null;
+ String validFrom3 = null;
+
+ String activationDate1 = null;
+ String activationDate2 = null;
+ String activationDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = PassTimeZoneTestTicketCase1V1.getUicTestTicket();
+ UicRailTicketData ticket2 = PassTimeZoneTestTicketCase2V1.getUicTestTicket();
+ UicRailTicketData ticket3 = PassTimeZoneTestTicketCase3V1.getUicTestTicket();
+
+ //encode in UTC time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+
+ encoded1 = UperEncoder.encode(ticket1);
+ encoded2 = UperEncoder.encode(ticket2);
+ encoded3 = UperEncoder.encode(ticket3);
+
+ }
+
+ /**
+ * clean up
+ */
+ @After public void resetTimeZone() {
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+ /**
+ * Test decode test tickets in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ */
+ @Test public void testCETdecodeOnly() throws IllegalArgumentException, IllegalAccessException {
+
+ encodedInTimeZone1 = encoded1;
+ encodedInTimeZone2 = encoded2;
+ encodedInTimeZone3 = encoded3;
+
+ decode("CET");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
+ assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
+
+ assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ }
+
+ /**
+ * Test decode test tickets in GMT.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ */
+ @Test public void testGMTdecodeOnly() throws IllegalArgumentException, IllegalAccessException {
+
+ encodedInTimeZone1 = encoded1;
+ encodedInTimeZone2 = encoded2;
+ encodedInTimeZone3 = encoded3;
+
+ //test decoded ticket
+ decode("GMT");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 12:30:00 GMT 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 00:30:00 GMT 2021" ));
+ assert(issuingDate3.equals("Wed Mar 03 23:30:00 GMT 2021" ));
+
+ assert(validFrom1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFrom2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFrom3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testCETCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone CET
+ TimeZone.setDefault(TimeZone.getTimeZone("CET"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00"));
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00"));
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidFrom(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00"));
+
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().add((new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00")));
+
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().add((new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00")));
+
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().add((new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00")));
+
+ encode("CET");
+ decode("CET");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
+ assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
+
+ assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ }
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testGMTCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone GMT
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00"));
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00"));
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidFrom(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00"));
+
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().add((new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00")));
+
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().add((new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00")));
+
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().add((new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00")));
+
+ encode("GMT");
+ decode("CET");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
+ assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
+
+ assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ }
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testCETGMTencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone GMT
+ TimeZone.setDefault(TimeZone.getTimeZone("CET"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00"));
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00"));
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidFrom(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00"));
+
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().add((new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00")));
+
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().add((new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00")));
+
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().add((new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse("2021.03.14-00:00")));
+
+ encode("CET");
+ decode("GMT");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 12:30:00 GMT 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 00:30:00 GMT 2021" ));
+ assert(issuingDate3.equals("Wed Mar 03 23:30:00 GMT 2021" ));
+
+ assert(validFrom1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFrom2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFrom3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ }
+
+ private void decodedDateToStrings() {
+
+ issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
+ issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
+ issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
+
+
+ validFrom1 = ((IPass) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom2 = ((IPass) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom3 = ((IPass) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
+
+ activationDate1 = ((IPass) iTicketDecodedCase1.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate2 = ((IPass) iTicketDecodedCase2.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate3 = ((IPass) iTicketDecodedCase3.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+
+ }
+
+
+
+ /**
+ * Encode in Time Zone
+ */
+ private void encode(String timeZone) {
+ TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
+ try {
+ encodedInTimeZone1 = encoder.encode(iTicketDecodedFromAsn1Case1);
+ encodedInTimeZone2 = encoder.encode(iTicketDecodedFromAsn1Case2);
+ encodedInTimeZone3 = encoder.encode(iTicketDecodedFromAsn1Case3);
+ } catch (EncodingFormatException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Decode in Time Zone
+ */
+ private void decode(String timeZone) {
+ TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
+
+ try {
+ iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
+ iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
+ iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ /**
+ * Encode decode.
+ */
+ private void decodeTestTicketUTC() {
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ try {
+ iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
+ iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
+ iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java b/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java
index 78deb8a..5bc419c 100644
--- a/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java
+++ b/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java
@@ -881,7 +881,7 @@ public class Api2OpenAsnEncoder {
asnData.setTariffs(encodeTariffCollection(document.getTariffs()));
- asnData.setActivatedDays(document.getActivatedDays(),document.getValidFrom());
+ asnData.addActivatedDays(DateTimeUtils.getActivatedDays(document.getValidFrom(), document.getActivatedDays()));
if (document.getClassCode() != ITravelClassType.second){
asnData.setClassCode(convertTravelClass(document.getClassCode()));
@@ -1558,13 +1558,7 @@ public class Api2OpenAsnEncoder {
}
- if(document.getActivatedDays()!= null && document.getActivatedDays().size() > 0) {
- if (document.getValidFrom() != null) {
- asnData.setActivatedDays(document.getActivatedDays(),document.getValidFrom());
- } else {
- asnData.setActivatedDays(document.getActivatedDays(),issuingDate);
- }
- }
+ asnData.addActivatedDays(DateTimeUtils.getActivatedDays(document.getValidFrom(), document.getActivatedDays()));
asnData.setClassCode(convertTravelClass(document.getClassCode()));
@@ -1697,9 +1691,7 @@ public class Api2OpenAsnEncoder {
asnData.setValidityDates(document.getValidFrom(), document.getValidUntil(), issuingDate);
- if(document.getActivatedDays()!= null && document.getActivatedDays().size() > 0) {
- asnData.setActivatedDays(document.getActivatedDays(), document.getValidFrom());
- }
+ asnData.addActivatedDays(DateTimeUtils.getActivatedDays(document.getValidFrom(), document.getActivatedDays()));
asnData.setExtension(encodeExtension(document.getExtension()));
diff --git a/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java b/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java
index 97abcfa..48583b9 100644
--- a/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java
+++ b/src/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java
@@ -886,7 +886,7 @@ public class Api2OpenAsnEncoderV2 {
asnData.setTariffs(encodeTariffCollection(document.getTariffs()));
- asnData.setActivatedDays(document.getActivatedDays(),document.getValidFrom());
+ asnData.addActivatedDays(DateTimeUtils.getActivatedDays(document.getValidFrom(), document.getActivatedDays()));
if (document.getClassCode() != ITravelClassType.second && document.getClassCode() != null){
asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
@@ -1562,14 +1562,8 @@ public class Api2OpenAsnEncoderV2 {
}
}
-
- if(document.getActivatedDays()!= null && document.getActivatedDays().size() > 0) {
- if (document.getValidFrom() != null) {
- asnData.setActivatedDays(document.getActivatedDays(),document.getValidFrom());
- } else {
- asnData.setActivatedDays(document.getActivatedDays(),issuingDate);
- }
- }
+ asnData.addActivatedDays(DateTimeUtils.getActivatedDays(document.getValidFrom(), document.getActivatedDays()));
+
if (document.getClassCode() != null) {
asnData.setClassCode(TravelClassType.valueOf(document.getClassCode().name()));
}
@@ -1703,9 +1697,7 @@ public class Api2OpenAsnEncoderV2 {
asnData.setValidityDates(document.getValidFrom(), document.getValidUntil(), issuingDate);
- if(document.getActivatedDays()!= null && document.getActivatedDays().size() > 0) {
- asnData.setActivatedDays(document.getActivatedDays(), document.getValidFrom());
- }
+ asnData.addActivatedDays(DateTimeUtils.getActivatedDays(document.getValidFrom(), document.getActivatedDays()));
asnData.setExtension(encodeExtension(document.getExtension()));
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/DateTimeUtils.java b/src/org/uic/barcode/ticket/api/utils/DateTimeUtils.java
index 6e62a4a..a0283c7 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/DateTimeUtils.java
+++ b/src/org/uic/barcode/ticket/api/utils/DateTimeUtils.java
@@ -1,6 +1,8 @@
-package org.uic.barcode.ticket.api.asn.omv1;
+package org.uic.barcode.ticket.api.utils;
+import java.util.ArrayList;
import java.util.Calendar;
+import java.util.Collection;
import java.util.Date;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
@@ -11,10 +13,41 @@ public class DateTimeUtils {
if (issuingDate == null || localDate == null) return null;
+ Calendar startCal = Calendar.getInstance();
+ startCal.clear();
+ startCal.setTime(issuingDate);
+ startCal.setTimeZone(TimeZone.getTimeZone("UTC"));
+ startCal.set(Calendar.HOUR_OF_DAY, 0);
+ startCal.set(Calendar.MINUTE, 0);
+ startCal.set(Calendar.SECOND, 0);
+ startCal.set(Calendar.MILLISECOND, 0);
+ Date start = startCal.getTime();
+
+ Calendar endCal = Calendar.getInstance();
+ endCal.clear();
+ endCal.setTime(localDate);
+ endCal.setTimeZone(TimeZone.getTimeZone("UTC"));
+ endCal.set(Calendar.HOUR_OF_DAY, 0);
+ endCal.set(Calendar.MINUTE, 0);
+ endCal.set(Calendar.SECOND, 0);
+ endCal.set(Calendar.MILLISECOND, 0);
+ Date end = endCal.getTime();
+
+ long diff = TimeUnit.DAYS.convert(end.getTime() - start.getTime(), TimeUnit.MILLISECONDS );
+ //long diff = localDate.getTime() - issuingDate.getTime();
+ //long dayDiff = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
+
+ return new Long(diff);
+
+ }
+
+ public static Long getDateDifferenceLocal(Date referenceDate, Date localDate) {
+
+ if (referenceDate == null || localDate == null) return null;
+
Calendar issuingCal = Calendar.getInstance();
issuingCal.clear();
- issuingCal.setTime(issuingDate);
- issuingCal.setTimeZone(TimeZone.getTimeZone("UTC"));
+ issuingCal.setTime(referenceDate);
issuingCal.set(Calendar.HOUR_OF_DAY, 0);
issuingCal.set(Calendar.MINUTE, 0);
issuingCal.set(Calendar.SECOND, 0);
@@ -23,13 +56,12 @@ public class DateTimeUtils {
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 diff = localDate.getTime() - referenceDate.getTime();
long dayDiff = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
return new Long(dayDiff);
@@ -122,12 +154,14 @@ public class DateTimeUtils {
cal.add(Calendar.DAY_OF_YEAR, date.intValue());
- DateTimeUtils.setTime(cal,time);
-
+ if (time == null) {
+ DateTimeUtils.setTime(cal,0L);
+ } else {
+ DateTimeUtils.setTime(cal,time);
+ }
return cal.getTime();
}
-
/**
@@ -193,6 +227,25 @@ public class DateTimeUtils {
return cal.getTime();
}
+
+
+ public static Collection<Long> getActivatedDays(Date referenceDate, Collection<Date> days) {
+
+ ArrayList<Long> lDays = new ArrayList<Long>();
+
+ if (referenceDate == null) return lDays;
+
+ for (Date day : days) {
+ long dateDiff2 = DateTimeUtils.getDateDifference(referenceDate,day);
+ lDays.add(dateDiff2);
+ }
+
+ return lDays;
+
+ }
+ public static Date dateToUTC(Date date){
+ return new Date(date.getTime() - Calendar.getInstance().getTimeZone().getOffset(date.getTime()));
+ }
}
diff --git a/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java b/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java
index 46f201d..46d2c1b 100644
--- a/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java
+++ b/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java
@@ -189,7 +189,12 @@ public class OpenAsn2ApiDecoder {
}
if (asnUicRailTicketData.getTransportDocument() != null && !asnUicRailTicketData.getTransportDocument().isEmpty()) {
- populateTravelDocuments(asnUicRailTicketData.getTransportDocument(),uicRailTicket,uicRailTicket.getIssuerDetails().getIssuingDate() );
+
+ // date is already converted to local time, use UTC for internal calculations
+ Date localIssuingDate = uicRailTicket.getIssuerDetails().getIssuingDate();
+ Date issuingDate = DateTimeUtils.dateToUTC(localIssuingDate);
+
+ populateTravelDocuments(asnUicRailTicketData.getTransportDocument(),uicRailTicket, issuingDate);
}
@@ -1627,13 +1632,7 @@ public class OpenAsn2ApiDecoder {
document.setValidUntil(asnDocument.getValidUntilDate(issuingDate));
document.setValidUntilUTCoffset(asnDocument.getValidUntilUTCOffset());
- if (asnDocument.getActivatedDay()!=null && !asnDocument.getActivatedDay().isEmpty()) {
- if (document.getValidFrom() != null) {
- document.getActivatedDays().addAll(asnDocument.getActivatedDays(document.getValidFrom()));
- } else {
- document.getActivatedDays().addAll(asnDocument.getActivatedDays(issuingDate));
- }
- }
+ document.getActivatedDays().addAll(asnDocument.getActivatedDays(issuingDate));
document.setExtension(convertExtension(asnDocument.getExtension()));
document.setInfoText(asnDocument.getInfoText());
diff --git a/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java b/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java
index 4aca9eb..c6eac0e 100644
--- a/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java
+++ b/src/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java
@@ -191,7 +191,12 @@ public class OpenAsn2ApiDecoderV2 {
}
if (asnUicRailTicketData.getTransportDocument() != null && !asnUicRailTicketData.getTransportDocument().isEmpty()) {
- populateTravelDocuments(asnUicRailTicketData.getTransportDocument(),uicRailTicket,uicRailTicket.getIssuerDetails().getIssuingDate() );
+
+ // date is already converted to local time, use UTC for internal calculations
+ Date localIssuingDate = uicRailTicket.getIssuerDetails().getIssuingDate();
+ Date issuingDate = DateTimeUtils.dateToUTC(localIssuingDate);
+
+ populateTravelDocuments(asnUicRailTicketData.getTransportDocument(),uicRailTicket, issuingDate);
}