Problem: Datetime overflow wraps around to next day
When parsing a timestamp with a value which is greater than the allowed range of values for the given component (e.g. hours are 0-23) the parser will interpret a higher value lenient. For example
20260528390000 will be accepted as
20260529150000
Use case
If any system transmits such a value I do not want to accept it and rather be alarmed and solve the underlying issue.
When manually editing a message, this doubles as somewhat of a safetynet against some, not all erronious inputs.
Solution
Change the server/src/com/mirth/connect/server/userutil/DateUtil.java so that either:
- lenient mode is inactive by default,
- lenient mode is configurable serverwide or
- the functions are overloaded with ones that accept an additional parameter to manually disable lenient mode
Code
wrapping:
DateUtil.getDate("yyyyMMddHHmmss", timestamp).getTime();
non wrapping:
var sdf = new java.text.SimpleDateFormat("yyyyMMddHHmmss");
sdf.setLenient(false);
sdf.parse(timestamp);
Problem: Datetime overflow wraps around to next day
When parsing a timestamp with a value which is greater than the allowed range of values for the given component (e.g. hours are 0-23) the parser will interpret a higher value lenient. For example
20260528390000 will be accepted as
20260529150000
Use case
If any system transmits such a value I do not want to accept it and rather be alarmed and solve the underlying issue.
When manually editing a message, this doubles as somewhat of a safetynet against some, not all erronious inputs.
Solution
Change the server/src/com/mirth/connect/server/userutil/DateUtil.java so that either:
Code
wrapping:
DateUtil.getDate("yyyyMMddHHmmss", timestamp).getTime();non wrapping:
var sdf = new java.text.SimpleDateFormat("yyyyMMddHHmmss");sdf.setLenient(false);sdf.parse(timestamp);