@Test void marshal_to_json() throws IOException { Distance distance = Distance.ofMillis(3_661_987); assertThat(json.write(PortableDistance.fromDistance(distance)).getJson()).isEqualTo("\"1h 1m 2s\""); }
static PortableDistance fromDistance(Distance distance) { long seconds = (Objects.requireNonNull(distance).millis() + 500) / 1000; return new PortableDistance(String.format("%dh %dm %ds", seconds / 3600, seconds / 60 % 60, seconds % 60)); }
PortableDistance { static PortableDistance fromDistance(Distance distance) { long seconds = (Objects.requireNonNull(distance).millis() + 500) / 1000; return new PortableDistance(String.format("%dh %dm %ds", seconds / 3600, seconds / 60 % 60, seconds % 60)); } }
PortableDistance { static PortableDistance fromDistance(Distance distance) { long seconds = (Objects.requireNonNull(distance).millis() + 500) / 1000; return new PortableDistance(String.format("%dh %dm %ds", seconds / 3600, seconds / 60 % 60, seconds % 60)); } private  PortableDistance(String distance); }
PortableDistance { static PortableDistance fromDistance(Distance distance) { long seconds = (Objects.requireNonNull(distance).millis() + 500) / 1000; return new PortableDistance(String.format("%dh %dm %ds", seconds / 3600, seconds / 60 % 60, seconds % 60)); } private  PortableDistance(String distance); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
PortableDistance { static PortableDistance fromDistance(Distance distance) { long seconds = (Objects.requireNonNull(distance).millis() + 500) / 1000; return new PortableDistance(String.format("%dh %dm %ds", seconds / 3600, seconds / 60 % 60, seconds % 60)); } private  PortableDistance(String distance); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }