mbeckerle commented on a change in pull request #70: Adding property
binaryCalendarRep with values "binarySeconds" and "bi…
URL: https://github.com/apache/incubator-daffodil/pull/70#discussion_r192197734
##########
File path:
daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesDateTime.scala
##########
@@ -191,26 +192,40 @@ abstract class ConvertBinaryCalendarPrimBase(e:
ElementBase, guard: Boolean, len
lazy val epochCalendar: Calendar = {
val cal = Calendar.getInstance
- val sdf = new SimpleDateFormat("uuuu-MM-dd'T'HH:mm:ss", ULocale.ENGLISH)
+ cal.clear()
+ cal.setLenient(false)
- val tz = {
- // If 'no time zone', then use UNKNOWN_ZONE
- //
- // UNKNOWN_ZONE behaves just like GMT/UTC and will
- // preserve the Date/Time values.
- //
- if (calendarTz.isDefined) calendarTz.get else TimeZone.UNKNOWN_ZONE
+ val sdfWithTZ = new SimpleDateFormat("uuuu-MM-dd'T'HH:mm:ssZZZZ",
ULocale.ENGLISH)
+ var pos = new ParsePosition(0)
+ sdfWithTZ.parse(e.binaryCalendarEpoch, cal, pos)
+
+ if (pos.getIndex != e.binaryCalendarEpoch.length || pos.getErrorIndex >=
0) {
+ // binaryCalendarEpoch didn't match the first format with timezone, so
try without
+ cal.clear()
+ pos = new ParsePosition(0)
+ val sdf = new SimpleDateFormat("uuuu-MM-dd'T'HH:mm:ss", ULocale.ENGLISH)
+ cal.setTimeZone(TimeZone.UNKNOWN_ZONE)
+ sdf.parse(e.binaryCalendarEpoch, cal, pos)
+
+ if (pos.getIndex != e.binaryCalendarEpoch.length || pos.getErrorIndex >=
0) {
+ SDE("Failed to parse binaryCalendarEpoch - Format must match the
pattern 'uuuu-MM-dd'T'HH:mm:ss' or 'uuuu-MM-dd'T'HH:mm:ssZZZZ'")
Review comment:
line too long for review tool. Can't see all the way right.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services