@Test public void testParseNanos() { assertEquals(1580605360001L, TimeEncoding.parse("2020-02-02T01:02:03.001Z")); assertEquals(1580605360001L, TimeEncoding.parse("2020-02-02T01:02:03.0010Z")); assertEquals(1580605360001L, TimeEncoding.parse("2020-02-02T01:02:03.00123Z")); assertEquals(1580605360001L, TimeEncoding.parse("2020-02-02T01:02:03.001234Z")); }
public static long parse(String s) { TaiUtcConverter.DateTimeComponents dtc; Matcher m = iso8601Pattern.matcher(s); if (m.matches()) { int year = Integer.parseInt(m.group(1)); int month = Integer.parseInt(m.group(2)); int day = Integer.parseInt(m.group(3)); int hour = Integer.parseInt(m.group(4)); int minute = Integer.parseInt(m.group(5)); int second = Integer.parseInt(m.group(6)); int millisec = 0; if (m.group(7) != null) { millisec = Integer.parseInt(m.group(8)); } dtc = new TaiUtcConverter.DateTimeComponents(year, month, day, hour, minute, second, millisec); } else { m = doyPattern.matcher(s); if (m.matches()) { int year = Integer.parseInt(m.group(1)); int doy = Integer.parseInt(m.group(2)); int hour = Integer.parseInt(m.group(3)); int minute = Integer.parseInt(m.group(4)); int second = Integer.parseInt(m.group(5)); int millisec = 0; if (m.group(6) != null) { millisec = Integer.parseInt(m.group(7)); } dtc = new TaiUtcConverter.DateTimeComponents(year, doy, hour, minute, second, millisec); } else { throw new IllegalArgumentException( "Cannot parse '" + s + "' with the pattern '" + iso8601Pattern + " or " + doyPattern); } } return taiUtcConverter.utcToInstant(dtc); }
TimeEncoding { public static long parse(String s) { TaiUtcConverter.DateTimeComponents dtc; Matcher m = iso8601Pattern.matcher(s); if (m.matches()) { int year = Integer.parseInt(m.group(1)); int month = Integer.parseInt(m.group(2)); int day = Integer.parseInt(m.group(3)); int hour = Integer.parseInt(m.group(4)); int minute = Integer.parseInt(m.group(5)); int second = Integer.parseInt(m.group(6)); int millisec = 0; if (m.group(7) != null) { millisec = Integer.parseInt(m.group(8)); } dtc = new TaiUtcConverter.DateTimeComponents(year, month, day, hour, minute, second, millisec); } else { m = doyPattern.matcher(s); if (m.matches()) { int year = Integer.parseInt(m.group(1)); int doy = Integer.parseInt(m.group(2)); int hour = Integer.parseInt(m.group(3)); int minute = Integer.parseInt(m.group(4)); int second = Integer.parseInt(m.group(5)); int millisec = 0; if (m.group(6) != null) { millisec = Integer.parseInt(m.group(7)); } dtc = new TaiUtcConverter.DateTimeComponents(year, doy, hour, minute, second, millisec); } else { throw new IllegalArgumentException( "Cannot parse '" + s + "' with the pattern '" + iso8601Pattern + " or " + doyPattern); } } return taiUtcConverter.utcToInstant(dtc); } }
TimeEncoding { public static long parse(String s) { TaiUtcConverter.DateTimeComponents dtc; Matcher m = iso8601Pattern.matcher(s); if (m.matches()) { int year = Integer.parseInt(m.group(1)); int month = Integer.parseInt(m.group(2)); int day = Integer.parseInt(m.group(3)); int hour = Integer.parseInt(m.group(4)); int minute = Integer.parseInt(m.group(5)); int second = Integer.parseInt(m.group(6)); int millisec = 0; if (m.group(7) != null) { millisec = Integer.parseInt(m.group(8)); } dtc = new TaiUtcConverter.DateTimeComponents(year, month, day, hour, minute, second, millisec); } else { m = doyPattern.matcher(s); if (m.matches()) { int year = Integer.parseInt(m.group(1)); int doy = Integer.parseInt(m.group(2)); int hour = Integer.parseInt(m.group(3)); int minute = Integer.parseInt(m.group(4)); int second = Integer.parseInt(m.group(5)); int millisec = 0; if (m.group(6) != null) { millisec = Integer.parseInt(m.group(7)); } dtc = new TaiUtcConverter.DateTimeComponents(year, doy, hour, minute, second, millisec); } else { throw new IllegalArgumentException( "Cannot parse '" + s + "' with the pattern '" + iso8601Pattern + " or " + doyPattern); } } return taiUtcConverter.utcToInstant(dtc); }  }
TimeEncoding { public static long parse(String s) { TaiUtcConverter.DateTimeComponents dtc; Matcher m = iso8601Pattern.matcher(s); if (m.matches()) { int year = Integer.parseInt(m.group(1)); int month = Integer.parseInt(m.group(2)); int day = Integer.parseInt(m.group(3)); int hour = Integer.parseInt(m.group(4)); int minute = Integer.parseInt(m.group(5)); int second = Integer.parseInt(m.group(6)); int millisec = 0; if (m.group(7) != null) { millisec = Integer.parseInt(m.group(8)); } dtc = new TaiUtcConverter.DateTimeComponents(year, month, day, hour, minute, second, millisec); } else { m = doyPattern.matcher(s); if (m.matches()) { int year = Integer.parseInt(m.group(1)); int doy = Integer.parseInt(m.group(2)); int hour = Integer.parseInt(m.group(3)); int minute = Integer.parseInt(m.group(4)); int second = Integer.parseInt(m.group(5)); int millisec = 0; if (m.group(6) != null) { millisec = Integer.parseInt(m.group(7)); } dtc = new TaiUtcConverter.DateTimeComponents(year, doy, hour, minute, second, millisec); } else { throw new IllegalArgumentException( "Cannot parse '" + s + "' with the pattern '" + iso8601Pattern + " or " + doyPattern); } } return taiUtcConverter.utcToInstant(dtc); }  static void setUp(); static void setUp(InputStream in); @Deprecated static long currentInstant(); static long getWallclockTime(); static String toString(long instant); static String toOrdinalDateTime(long instant); static String toWinCompatibleDateTime(long instant); static String toCombinedFormat(long instant); static long fromGpsCcsdsTime(int coarseTime, byte fineTime); static GpsCcsdsTime toGpsTime(final long instant); static GpsCcsdsTime getCurrentGpsTime(); static long toGpsTimeMillisec(final long instant); static long fromGpsYearSecMillis(int year, int secOfYear, int millis); static TaiUtcConverter.DateTimeComponents toUtc(long instant); static List<ValidityLine> getTaiUtcConversionTable(); static long parse(String s); @Deprecated static long fromUnixTime(long milliseconds); static long fromUnixMillisec(long milliseconds); static long fromUnixTime(long seconds, int microseconds); static long toUnixMillisec(long instant); static long fromCalendar(Calendar cal); static long fromDate(Date date); static Calendar toCalendar(long instant); static long getJavaGpsFromInstant(long instant); static long getInstantfromJavaGps(long javagps); static long fromGpsMillisec(long gpstime); static long fromTaiMillisec(long taitime); static long toTaiMillisec(long instant); static long fromJ2000Millisec(long j2000time); static long toJ2000Millisec(long instant); static long fromProtobufTimestamp(Timestamp ts); static Timestamp toProtobufTimestamp(long instant); }
TimeEncoding { public static long parse(String s) { TaiUtcConverter.DateTimeComponents dtc; Matcher m = iso8601Pattern.matcher(s); if (m.matches()) { int year = Integer.parseInt(m.group(1)); int month = Integer.parseInt(m.group(2)); int day = Integer.parseInt(m.group(3)); int hour = Integer.parseInt(m.group(4)); int minute = Integer.parseInt(m.group(5)); int second = Integer.parseInt(m.group(6)); int millisec = 0; if (m.group(7) != null) { millisec = Integer.parseInt(m.group(8)); } dtc = new TaiUtcConverter.DateTimeComponents(year, month, day, hour, minute, second, millisec); } else { m = doyPattern.matcher(s); if (m.matches()) { int year = Integer.parseInt(m.group(1)); int doy = Integer.parseInt(m.group(2)); int hour = Integer.parseInt(m.group(3)); int minute = Integer.parseInt(m.group(4)); int second = Integer.parseInt(m.group(5)); int millisec = 0; if (m.group(6) != null) { millisec = Integer.parseInt(m.group(7)); } dtc = new TaiUtcConverter.DateTimeComponents(year, doy, hour, minute, second, millisec); } else { throw new IllegalArgumentException( "Cannot parse '" + s + "' with the pattern '" + iso8601Pattern + " or " + doyPattern); } } return taiUtcConverter.utcToInstant(dtc); }  static void setUp(); static void setUp(InputStream in); @Deprecated static long currentInstant(); static long getWallclockTime(); static String toString(long instant); static String toOrdinalDateTime(long instant); static String toWinCompatibleDateTime(long instant); static String toCombinedFormat(long instant); static long fromGpsCcsdsTime(int coarseTime, byte fineTime); static GpsCcsdsTime toGpsTime(final long instant); static GpsCcsdsTime getCurrentGpsTime(); static long toGpsTimeMillisec(final long instant); static long fromGpsYearSecMillis(int year, int secOfYear, int millis); static TaiUtcConverter.DateTimeComponents toUtc(long instant); static List<ValidityLine> getTaiUtcConversionTable(); static long parse(String s); @Deprecated static long fromUnixTime(long milliseconds); static long fromUnixMillisec(long milliseconds); static long fromUnixTime(long seconds, int microseconds); static long toUnixMillisec(long instant); static long fromCalendar(Calendar cal); static long fromDate(Date date); static Calendar toCalendar(long instant); static long getJavaGpsFromInstant(long instant); static long getInstantfromJavaGps(long javagps); static long fromGpsMillisec(long gpstime); static long fromTaiMillisec(long taitime); static long toTaiMillisec(long instant); static long fromJ2000Millisec(long j2000time); static long toJ2000Millisec(long instant); static long fromProtobufTimestamp(Timestamp ts); static Timestamp toProtobufTimestamp(long instant); static final long INVALID_INSTANT; static final long MIN_INSTANT; static long MAX_INSTANT; }