MCPcopy Create free account
hub / github.com/MenoData/Time4J / format

Method format

base/src/main/java/net/time4j/PrettyTime.java:1874–1906  ·  view source on GitHub ↗
(
        long amount,
        IsoUnit unit,
        boolean negative,
        TextWidth width
    )

Source from the content-addressed store, hash-verified

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,

Callers 4

printMethod · 0.95
printRelativeOrDateMethod · 0.95
printRelativeSecondsMethod · 0.95
printRelativeTimeMethod · 0.95

Calls 12

safeNegateMethod · 0.95
printMethod · 0.95
replaceMethod · 0.80
hasDecimalCodepointsMethod · 0.80
containsMethod · 0.65
isCalendricalMethod · 0.65
toStringMethod · 0.65
toNumeralMethod · 0.65
castMethod · 0.45
lengthMethod · 0.45
valueOfMethod · 0.45
absMethod · 0.45

Tested by

no test coverage detected