(
long amount,
IsoUnit unit,
boolean negative,
TextWidth width
)
| 1872 | } |
| 1873 | |
| 1874 | private String format( |
| 1875 | long amount, |
| 1876 | IsoUnit unit, |
| 1877 | boolean negative, |
| 1878 | TextWidth width |
| 1879 | ) { |
| 1880 | long value = amount; |
| 1881 | |
| 1882 | if (negative) { |
| 1883 | value = MathUtils.safeNegate(amount); |
| 1884 | } |
| 1885 | |
| 1886 | if (SUPPORTED_UNITS.contains(unit)) { |
| 1887 | if (unit.isCalendrical()) { |
| 1888 | CalendarUnit u = CalendarUnit.class.cast(unit); |
| 1889 | return this.print(value, u, width); |
| 1890 | } else { |
| 1891 | ClockUnit u = ClockUnit.class.cast(unit); |
| 1892 | if (u == NANOS) { |
| 1893 | if ((amount % MIO) == 0) { |
| 1894 | u = MILLIS; |
| 1895 | value = value / MIO; |
| 1896 | } else if ((amount % 1000) == 0) { |
| 1897 | u = MICROS; |
| 1898 | value = value / 1000; |
| 1899 | } |
| 1900 | } |
| 1901 | return this.print(value, u, width); |
| 1902 | } |
| 1903 | } |
| 1904 | |
| 1905 | throw new UnsupportedOperationException("Unknown unit: " + unit); |
| 1906 | } |
| 1907 | |
| 1908 | private String format( |
| 1909 | String pattern, |
no test coverage detected