Skip to content

Allow configuration of non-lenient datetime parsing #164

Description

@Tim-Hennig

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);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions