diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/gv/util/MiscUtil.java | 16 | ||||
-rw-r--r-- | src/main/java/at/gv/util/data/ElectronicIdentity.java | 5 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/main/java/at/gv/util/MiscUtil.java b/src/main/java/at/gv/util/MiscUtil.java index 7ad055e..c0095f8 100644 --- a/src/main/java/at/gv/util/MiscUtil.java +++ b/src/main/java/at/gv/util/MiscUtil.java @@ -276,11 +276,27 @@ public class MiscUtil { } } + /** + * Parse XML date in date object in UTC timezone + * + * @param xmlDate String based date with pattern "yyyy-MM-dd" + * @return + * @throws EgovUtilException + */ public static Date parseXMLDate(String xmlDate) throws EgovUtilException { + return parseXMLDate(xmlDate, TimeZone.getTimeZone("UTC")); + + } + + public static Date parseXMLDate(String xmlDate, TimeZone zone) throws EgovUtilException { if (xmlDate == null) { return null; } SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + if (zone != null) + sdf.setTimeZone(zone); + try { return sdf.parse(xmlDate); } catch (ParseException e) { diff --git a/src/main/java/at/gv/util/data/ElectronicIdentity.java b/src/main/java/at/gv/util/data/ElectronicIdentity.java index 4483e86..ea5bd25 100644 --- a/src/main/java/at/gv/util/data/ElectronicIdentity.java +++ b/src/main/java/at/gv/util/data/ElectronicIdentity.java @@ -30,6 +30,7 @@ import java.util.List; import java.util.Properties; import java.util.Set; import java.util.StringTokenizer; +import java.util.TimeZone; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; @@ -378,7 +379,7 @@ public final class ElectronicIdentity implements Serializable, Empty, RoleContai this.baseId = ppt.getIdentification().get(0).getValue().getValue(); this.firstName = ppt.getName().getGivenName().get(0); this.lastName = ppt.getName().getFamilyName().get(0).getValue(); - this.dateOfBirth = MiscUtil.parseXMLDate(ppt.getDateOfBirth()); + this.dateOfBirth = MiscUtil.parseXMLDate(ppt.getDateOfBirth(), TimeZone.getTimeZone("UTC")); } } } @@ -451,7 +452,7 @@ public final class ElectronicIdentity implements Serializable, Empty, RoleContai this.setBaseId(baseId); this.setZbpk(BpkUtil.calcZBPK(baseId)); this.setVzbpk(BpkUtil.calcVZBPK(baseId)); - this.setDateOfBirth(MiscUtil.parseXMLDate(ppt.getDateOfBirth())); + this.setDateOfBirth(MiscUtil.parseXMLDate(ppt.getDateOfBirth(), TimeZone.getTimeZone("UTC"))); this.setFirstName(ppt.getName().getGivenName().get(0)); this.setLastName(ppt.getName().getFamilyName().get(0).getValue()); } else if ("bkuURL".equals(attr.getAttributeName())) { |