### Question:
Duration { public static String toString(final long milliSeconds) { final StringBuilder buff = new StringBuilder(); final List<Pair<Long, String>> list = Arrays.asList( new Pair<>(1L, (String) null), new Pair<>(1L, "ミリ秒"), new Pair<>(SECOND, "秒"), new Pair<>(MINUTE, "分"), new Pair<>(HOUR, "時間"), new Pair<>(DAY, "日"), new Pair<>(MONTH, "ヶ月"), new Pair<>(YEAR, "年"), new Pair<>(Long.MAX_VALUE, (String) null) ); for (int i = 1; i < list.size() - 1; i++) { if (milliSeconds < list.get(i + 1).getFirst()) { final long unit = list.get(i).getFirst(); final long val = Math.round(milliSeconds / (double) unit); buff.append(val).append(list.get(i).getSecond()); if (Math.abs(val * unit - milliSeconds) >= list.get(i - 1).getFirst()) { buff.append("くらい"); } return buff.toString(); } } return "気が遠くなるほどの期間"; } private  Duration(); static String toString(final long milliSeconds); static final long SECOND; static final long MINUTE; static final long HOUR; static final long DAY; static final long MONTH; static final long YEAR; }### Answer:
@Test public void testToString() { Assert.assertEquals("0ミリ秒", Duration.toString(0L)); Assert.assertEquals("1ミリ秒", Duration.toString(1L)); Assert.assertEquals("999ミリ秒", Duration.toString(999L)); Assert.assertEquals("1秒", Duration.toString(Duration.SECOND)); Assert.assertEquals("1秒くらい", Duration.toString(Duration.SECOND + 1)); Assert.assertEquals("9秒くらい", Duration.toString(10 * Duration.SECOND - 501)); Assert.assertEquals("10秒くらい", Duration.toString(10 * Duration.SECOND - 500)); Assert.assertEquals("10秒くらい", Duration.toString(10 * Duration.SECOND - 1)); Assert.assertEquals("10秒", Duration.toString(10 * Duration.SECOND)); Assert.assertEquals("10秒くらい", Duration.toString(10 * Duration.SECOND + 1)); Assert.assertEquals("10秒くらい", Duration.toString(10 * Duration.SECOND + 499)); Assert.assertEquals("11秒くらい", Duration.toString(10 * Duration.SECOND + 500)); }