Class ByteSizeFormatter

  • All Implemented Interfaces:
    Serializable, org.apache.wicket.util.io.IClusterable

    public class ByteSizeFormatter
    extends Object
    implements org.apache.wicket.util.io.IClusterable
    Formats numeric byte values into human-readable strings.
    See Also:
    Serialized Form
    • Constructor Detail

      • ByteSizeFormatter

        public ByteSizeFormatter()
      • ByteSizeFormatter

        public ByteSizeFormatter​(int decimalPlaces)
      • ByteSizeFormatter

        public ByteSizeFormatter​(String gigabyteSuffix,
                                 String megabyteSuffix,
                                 String kilobyteSuffix,
                                 String byteSuffix,
                                 int decimalPlaces)
    • Method Detail

      • format

        public String format​(long filesize)
        Formats filesize in bytes as appropriate to bytes, KB, MB or GB. By default, it formats based on the current user's locale information if available.
        Parameters:
        filesize - in bytes
        Returns:
        formatted filesize
      • format

        public String format​(long filesize,
                             Locale loc)
        Formats filesize in bytes as appropriate to bytes, KB, MB or GB, based on the given locale. If the locale is null, then the default locale will be used.
        Parameters:
        filesize - in bytes
        loc - Locale
        Returns:
        formatted filesize