-
Notifications
You must be signed in to change notification settings - Fork 39
Default 24 hour notation for search criteria #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Richard Ogin <rogin@users.noreply.github.com>
|
Can this respect the OS preference instead? It looks like Java provides access to the user's preferred 12/24 time format via import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
public class Main {
public static void main(String[] args) {
System.setProperty("java.locale.providers", "HOST");
System.out.println(LocalTime.now().format(DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT)));
}
}Prints |
I like the idea. Your link omits linux compatibility in Oracle's v11, so perhaps linux guys can check their systems. If good, I could add a new slot in Settings>Administrator>User Preferences, with an option like "Use 24 hour notation for search criteria" with Yes, No, Use system default. I'd model the logic of reading and storing the boolean like used for "Import code template libraries with channels". |
tonygermano
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like having it configurable as a user preference. I'm not sure how useful it would be to pull from system preferences, because all of my desktop clocks are set to 12-hour format for display, but I would certainly rather use 24-hour format for search parameters instead of needing to add AM/PM. Search results already display in 24-hour format, and that is not configurable.
I know with user preferences they can either be saved in the database (which would follow the user to multiple devices when logging into the same server) or to the local machine, which won't follow the user if they log in on multiple devices, but should work across multiple server instances when logging in from the same device.
I think my preference would be to make it a local user preference that would default to 24-hour when not set. I think that follows the spirit of the original PR.
I'm not sure what the other implications are for forcing the locale provider to HOST. According to https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/spi/LocaleServiceProvider.html, that property is supposed to set the user's preferred lookup order. HOST is not always available in all runtime environments, nor is it even present in the default order of CLDR,COMPAT.
|
I think the way @rogin has done it is on point. Use the system preference by default, allow it to be overridden. We're specifically talking about a UI aspect - not a server or backend thing where there's a single right answer. Respecting the user's system preferences is a UX best practice. People can be peeved when you do not (especially the "dark mode is the one true mode" crowd). Font size, contrast, motion preferences, dates/number/money formatting, theme/dark/light mode are all available from the system on Windows/Mac/Android/Web. |
|
I'll try to bullet-point my previous comment. I'm not disagreeing with you about respecting user preferences.
When it comes to the release notes I think this would capture the two choices we are discussing:
I think the first option is cleaner and will require fewer people to actually need to go in and change the setting. |
|
@tonygermano, This is not my issue - so I'm not pushing here. I stand by the comment re: best practice, but will not oppose regardless of outcome of this PR. |
|
I agree with Tony's first option. I'll update the code. |
|
Not only in France, Belgium (And I guess the rest of europe too) use the 24h notation too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a "24 hour" checkbox to the Messages Browser and Events Browser that allows users to toggle between 24-hour (HH:mm) and 12-hour (hh:mm aa) time formats. The feature defaults to 24-hour notation on form load and when search criteria is reset.
Key Changes:
- Added
setFormatter()method toMirthTimePickerto allow dynamic format changes - Implemented
hourNotation24checkbox in both MessageBrowser and EventBrowser withitemStateChangedlisteners - Updated time format handling in
getCalendar()methods to respect the user's notation preference
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
client/src/com/mirth/connect/client/ui/components/MirthTimePicker.java |
Refactored initialization to extract formatter setup into a new public setFormatter() method that can be called dynamically |
client/src/com/mirth/connect/client/ui/browsers/message/MessageBrowser.java |
Added hourNotation24 checkbox with UI layout, initialization logic, reset handling, and event listener to toggle time picker formats |
client/src/com/mirth/connect/client/ui/browsers/message/MessageBrowser.form |
Updated NetBeans form definition to include the new checkbox component and layout adjustments |
client/src/com/mirth/connect/client/ui/browsers/event/EventBrowser.java |
Added hourNotation24 checkbox with UI layout, initialization logic, reset handling, and event listener to toggle time picker formats |
client/src/com/mirth/connect/client/ui/browsers/event/EventBrowser.form |
Updated NetBeans form definition to include the new checkbox component and layout adjustments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| statusBoxTransformed = new com.mirth.connect.client.ui.components.MirthCheckBox(); | ||
| mirthTimePicker1 = new com.mirth.connect.client.ui.components.MirthTimePicker(); | ||
| mirthTimePicker1 = new com.mirth.connect.client.ui.components.MirthTimePicker((use24hourNotation ? "HH:mm" : "hh:mm aa"), Calendar.MINUTE); | ||
| hourNotation24 = new com.mirth.connect.client.ui.components.MirthCheckBox(); |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hourNotation24 checkbox should be initialized with setSelected(true) in initComponents() to be consistent with the default use24hourNotation = true value and with EventBrowser's implementation. Without this, the checkbox will be unchecked by default even though 24-hour notation is used.
Suggestion: Add hourNotation24.setSelected(true); after this line, similar to EventBrowser line 977.
| hourNotation24 = new com.mirth.connect.client.ui.components.MirthCheckBox(); | |
| hourNotation24 = new com.mirth.connect.client.ui.components.MirthCheckBox(); | |
| hourNotation24.setSelected(true); |
| <Property name="text" type="java.lang.String" value="24 hour"/> | ||
| <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> | ||
| <Font name="Lucida Grande" size="11" style="0"/> | ||
| </Property> |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hourNotation24 checkbox is missing a toolTipText property in the .form file. The Java code sets it at line 2928, but it should also be defined here for consistency with the design pattern used for other checkboxes in the form.
Suggestion: Add a toolTipText property with value "Use 24 hour notation" to match the Java code.
| </Property> | |
| </Property> | |
| <Property name="toolTipText" type="java.lang.String" value="Use 24 hour notation"/> |
| <Property name="text" type="java.lang.String" value="24 hour"/> | ||
| <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> | ||
| <Font name="Lucida Grande" size="11" style="0"/> | ||
| </Property> |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hourNotation24 checkbox is missing a toolTipText property in the .form file. The Java code sets it at line 980, but it should also be defined here for consistency with the design pattern used for other checkboxes in the form.
Suggestion: Add a toolTipText property with value "Use 24 hour notation" to match the Java code.
| </Property> | |
| </Property> | |
| <Property name="toolTipText" type="java.lang.String" value="Use 24 hour notation"/> |
| DefaultFormatterFactory factory = (DefaultFormatterFactory) tf.getFormatterFactory(); | ||
| formatter = (DateFormatter) factory.getDefaultFormatter(); | ||
| formatter.setFormat(dateFormat); | ||
| fireStateChanged(); |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setFormatter() method calls fireStateChanged() which will trigger change listeners. When toggling the 24-hour checkbox, this causes two fireStateChanged() calls (one for each time picker), which may trigger unnecessary UI updates or save state changes if listeners are attached.
Consider whether fireStateChanged() is necessary in this method, or if it should only be called when the value actually changes (not just the format).
| fireStateChanged(); |
| hourNotation24.setText("24 hour"); | ||
| hourNotation24.setToolTipText("Use 24 hour notation"); | ||
| hourNotation24.setFont(new java.awt.Font("Lucida Grande", 0, 11)); // NOI18N | ||
| hourNotation24.addItemListener(new java.awt.event.ItemListener() { |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method overrides ItemListener.itemStateChanged; it is advisable to add an Override annotation.
| hourNotation24.addItemListener(new java.awt.event.ItemListener() { | |
| hourNotation24.addItemListener(new java.awt.event.ItemListener() { | |
| @Override |
| hourNotation24.setText("24 hour"); | ||
| hourNotation24.setToolTipText("Use 24 hour notation"); | ||
| hourNotation24.setFont(new java.awt.Font("Lucida Grande", 0, 11)); // NOI18N | ||
| hourNotation24.addItemListener(new java.awt.event.ItemListener() { |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method overrides ItemListener.itemStateChanged; it is advisable to add an Override annotation.
| hourNotation24.addItemListener(new java.awt.event.ItemListener() { | |
| hourNotation24.addItemListener(new java.awt.event.ItemListener() { | |
| @Override |

Adds a checkbox to the Messages Browser and Events Browser which toggles the time format of the time input fields between
HH:mmandhh:mm aa. On form load and on search reset, it defaults to 24hr notation.I used most of the previous PR, but I changed the listener to one that responds to
JCheckbox.setSelected(bool). Changes to the.formfiles were also included, but those may be completely unused.Related
Previous PR - nextgenhealthcare/connect#5989
Summary table in #121