java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JComboBox
com.github.lgooddatepicker.durationpicker_underconstruction.DurationPicker
All Implemented Interfaces:
ActionListener, ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, ListDataListener

public class DurationPicker extends JComboBox
DurationPicker, This component allows a user to select a duration. Durations can be entered using the mouse or keyboard. The picker can parse multiple formats. For example, when using English language units, all of the following strings would be successfully parsed and stored as a duration: "1 minute", "1m", "2 hours", "2.732 hours", "5 days", "4 weeks", "3 months", "2 years". Even though multiple formats can be parsed by the duration picker, all durations are converted to a standard format for display. The duration picker will only display one unit at a time. For example, the duration picker may display "9 days", but it will never display "1 week, 2 days". Actual months vary in length by month-of-year. Within the context of the "Duration" and "DurationPicker" classes, the month and year units are defined using an average, fixed estimated length. These estimates are supplied by the class "java.time.temporal.ChronoUnit". The estimated duration of a year is 365.2425 Days (31556952L seconds). The estimated duration of a month is one twelfth of 365.2425 Days (2629746L seconds). When representing a duration as a string, the duration picker will choose the largest unit that is available for use, that divides evenly into the duration that is being represented. For example, 14 days can display as "2 weeks", but 15 days will display as "15 days" (or as a smaller unit if the settings indicate that the days unit should not be used.) If fractional durations are entered by the user, this can result in large, unwieldy numbers being displayed. For example, if the user entered 3.632 hours, then the duration picker would display this as 13075 seconds.
See Also:
  • Constructor Details

    • DurationPicker

      public DurationPicker()
    • DurationPicker

      public DurationPicker(DurationConverterSettings converterSettings)
  • Method Details

    • setDuration

      public void setDuration(Duration duration)
    • getDuration

      public Duration getDuration()
    • setText

      public void setText(String text)
    • getText

      public String getText()
    • setMenuItems

      public void setMenuItems(ArrayList<Duration> menuItemDurations)
    • getMenuItems

      public ArrayList<Duration> getMenuItems()