Fixed that if date or time is not set nothing gets written to output (instead of 0 which is an invalid value so that message get discarded)
This commit is contained in:
parent
9a6c3b0821
commit
3ccef79596
|
@ -17,10 +17,21 @@ open class Datum(date: Int, existenzstatus: Existenzstatus) : NumerischesDatenel
|
|||
const val HbciDateFormatString = "yyyyMMdd"
|
||||
|
||||
val HbciDateFormat = SimpleDateFormat(HbciDateFormatString)
|
||||
|
||||
const val DateNotSet = Int.MIN_VALUE
|
||||
}
|
||||
|
||||
|
||||
constructor(date: Date?, existenzstatus: Existenzstatus)
|
||||
: this(date?.let { HbciDateFormat.format(it).toInt() } ?: 0, existenzstatus)
|
||||
: this(date?.let { HbciDateFormat.format(it).toInt() } ?: DateNotSet, existenzstatus)
|
||||
|
||||
|
||||
override fun format(): String {
|
||||
if (value == DateNotSet) {
|
||||
return "" // optional element and value not set -> write nothing to output
|
||||
}
|
||||
|
||||
return super.format()
|
||||
}
|
||||
|
||||
}
|
|
@ -18,10 +18,21 @@ open class Uhrzeit(time: Int, existenzstatus: Existenzstatus) : ZiffernDatenelem
|
|||
const val HbciTimeFormatString = "HHmmss"
|
||||
|
||||
val HbciTimeFormat = SimpleDateFormat(HbciTimeFormatString)
|
||||
|
||||
const val TimeNotSet = Int.MIN_VALUE
|
||||
}
|
||||
|
||||
|
||||
constructor(time: Date?, existenzstatus: Existenzstatus)
|
||||
: this(time?.let { HbciTimeFormat.format(it).toInt() } ?: 0, existenzstatus)
|
||||
|
||||
|
||||
override fun format(): String {
|
||||
if (value == TimeNotSet) {
|
||||
return "" // optional element and value not set -> write nothing to output
|
||||
}
|
||||
|
||||
return super.format()
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue