All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class Epochextends JFrame
Small swing-based utility to convert timestamps (seconds since epoch) to readable dates and vice versa. Supports at-style time specification (like "now-2d", "noon yesterday") and other human-readable data formats:
  • MM/dd/yy HH:mm:ss
  • dd.MM.yy HH:mm:ss
  • dd.MM.yy HH:mm:ss
  • MM/dd/yy HH:mm
  • dd.MM.yy HH:mm
  • yy-MM-dd HH:mm
  • MM/dd/yy
  • dd.MM.yy
  • yy-MM-dd
  • HH:mm MM/dd/yy
  • HH:mm dd.MM.yy
  • HH:mm yy-MM-dd
  • HH:mm:ss MM/dd/yy
  • HH:mm:ss dd.MM.yy
  • HH:mm:ss yy-MM-dd
The current timestamp is displayed in the title bar :)
See Also:
  • Field Details

    • supportedFormats

      private final String[] supportedFormats
      Supported formats
    • parsers

      private final SimpleDateFormat[] parsers
      One lenient parser per entry of supportedFormats, tried in order when parsing input.
    • helpText

      private final String helpText
      Help text
    • topLabel

      private final JLabel topLabel
      Top label
    • inputField

      private final JTextField inputField
      Input field
    • convertButton

      private final JButton convertButton
      Convert button
    • helpButton

      private final JButton helpButton
      Help button
    • OUTPUT_DATE_FORMAT

      private final SimpleDateFormat OUTPUT_DATE_FORMAT
      Format pattern for the output date.
  • Constructor Details

    • Epoch

      private Epoch()
      Starts the epoch converter window.
  • Method Details

    • constructUI

      private void constructUI()
      Builds the converter's text fields and buttons.
    • centerOnScreen

      private void centerOnScreen()
      Places the window in the middle of the screen.
    • convert

      private void convert()
      Converts the entered epoch or date and shows the result.
    • showTimestamp

      private void showTimestamp()
      Shows the current time as an epoch value.
    • formatDate

      private void formatDate(Date date)
      Writes a date into the epoch field.
      Parameters:
      date - the date to show
    • parseDate

      private long parseDate(String time)
      Reads a date from the text field.
      Parameters:
      time - the text to parse
      Returns:
      the epoch seconds it names
    • main

      public static void main(String[] args)
      Main method which runs this utility.
      Parameters:
      args - Not used; the timestamp is read from stdin.