From 774af5d220708822b70d018bfcb2d77e9e274148 Mon Sep 17 00:00:00 2001 From: Enrique Zamudio Date: Tue, 17 Apr 2018 12:16:49 -0500 Subject: [PATCH] add timezone to template fields #106 --- .../com/solab/iso8583/parse/ConfigParser.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/solab/iso8583/parse/ConfigParser.java b/src/main/java/com/solab/iso8583/parse/ConfigParser.java index bb14d8a..0592d7e 100644 --- a/src/main/java/com/solab/iso8583/parse/ConfigParser.java +++ b/src/main/java/com/solab/iso8583/parse/ConfigParser.java @@ -275,8 +275,13 @@ public class ConfigParser { } } } - return itype.needsLength() ? new IsoValue<>(itype, cf, length, cf) : + IsoValue rv = itype.needsLength() ? new IsoValue<>(itype, cf, length, cf) : new IsoValue<>(itype, cf, cf); + if (f.hasAttribute("tz")) { + TimeZone tz = TimeZone.getTimeZone(f.getAttribute("tz")); + rv.setTimeZone(tz); + } + return rv; } final String v; if (f.getChildNodes().getLength() == 0) { @@ -285,11 +290,13 @@ public class ConfigParser { v = f.getChildNodes().item(0).getNodeValue(); } final CustomField cf = toplevel ? mfact.getCustomField(num) : null; + IsoValue rv; if (cf == null) { - return itype.needsLength() ? new IsoValue<>(itype, v, length) : new IsoValue<>(itype, v); + rv = itype.needsLength() ? new IsoValue<>(itype, v, length) : new IsoValue<>(itype, v); + } else { + rv = itype.needsLength() ? new IsoValue<>(itype, cf.decodeField(v), length, cf) : + new IsoValue<>(itype, cf.decodeField(v), cf); } - IsoValue rv = itype.needsLength() ? new IsoValue<>(itype, cf.decodeField(v), length, cf) : - new IsoValue<>(itype, cf.decodeField(v), cf); if (f.hasAttribute("tz")) { TimeZone tz = TimeZone.getTimeZone(f.getAttribute("tz")); rv.setTimeZone(tz); @@ -298,7 +305,7 @@ public class ConfigParser { } protected static FieldParseInfo getParser( - Element f, MessageFactory mfact) throws IOException { + Element f, MessageFactory mfact) { IsoType itype = IsoType.valueOf(f.getAttribute("type")); int length = 0; if (f.getAttribute("length").length() > 0) {