@Test
  public void testFormats() {
    final TimeInstant now = TimeInstantBuilder.fromNow();

    final String date = now.formatted(TimeInstant.STD_DATE_FMT);
    Assert.assertTrue(Pattern.matches("\\d\\d\\d\\d-\\d\\d-\\d\\d", date));

    final String time = now.formatted(TimeInstant.STD_TIME_FMT);
    Assert.assertTrue(Pattern.matches("\\d\\d:\\d\\d:\\d\\d", time));

    final String timeFS = now.formatted(TimeInstant.STD_TIME_FMT_FOR_FS);
    Assert.assertTrue(Pattern.matches("\\d\\d_\\d\\d_\\d\\d", timeFS));

    final String dateTime = now.formatted(TimeInstant.STD_DATETIME_FMT);
    Assert.assertTrue(
        Pattern.matches("\\d\\d\\d\\d-\\d\\d-\\d\\d\\s\\d\\d:\\d\\d:\\d\\d", dateTime));

    final String dateTimeWithMS = now.formatted(TimeInstant.STD_DATETIME_FMT_WITH_MILLIS);
    Assert.assertTrue(
        Pattern.matches(
            "\\d\\d\\d\\d-\\d\\d-\\d\\d\\s\\d\\d:\\d\\d:\\d\\d\\.\\d\\d\\d", dateTimeWithMS));

    final String dateTimeFS = now.formatted(TimeInstant.STD_DATETIME_FMT_FOR_FS);
    Assert.assertTrue(
        Pattern.matches("\\d\\d\\d\\d-\\d\\d-\\d\\d_\\d\\dh\\d\\dm\\d\\ds", dateTimeFS));
  }
  @Test
  public void compareTimeTest() {
    final TimeInstant first = TimeInstantBuilder.fromMillis(0L);
    final TimeInstant now = TimeInstantBuilder.fromNow();

    Assert.assertEquals(0, first.compareTo(first));
    Assert.assertEquals(-1, first.compareTo(now));
    Assert.assertEquals(1, now.compareTo(first));
    Assert.assertFalse(first.equals(now));
    Assert.assertFalse(first.equals(now));
    Assert.assertFalse(first.getInstant().equals(now.getInstant()));

    final TimeInstant t1 = TimeInstantBuilder.fromMillis(123456L);
    final TimeInstant t2 = TimeInstantBuilder.fromMillis(123456L);
    Assert.assertEquals(0, t1.compareTo(t2));
    Assert.assertEquals(0, t2.compareTo(t1));
    Assert.assertTrue(t1.equals(t2));
    Assert.assertTrue(t2.equals(t1));
    Assert.assertTrue(t1.getInstant().equals(t2.getInstant()));
    Assert.assertFalse(t1.isAfter(t2));
    Assert.assertFalse(t2.isAfter(t1));
    Assert.assertFalse(t1.isBefore(t2));
    Assert.assertFalse(t2.isBefore(t1));

    final TimeInstant t3 = TimeInstantBuilder.fromNanos(123456000000L);
    final TimeInstant t4 = TimeInstantBuilder.fromNanos(123456000001L);
    Assert.assertEquals(-1, t3.compareTo(t4));
    Assert.assertEquals(1, t4.compareTo(t3));
    Assert.assertFalse(t3.equals(t4));
    Assert.assertFalse(t4.equals(t3));
    Assert.assertTrue(t3.getInstant().equals(t4.getInstant()));
    Assert.assertFalse(t3.isAfter(t4));
    Assert.assertTrue(t4.isAfter(t3));
    Assert.assertTrue(t3.isBefore(t4));
    Assert.assertFalse(t4.isBefore(t3));
  }