Java Size createSizeFormat(Locale locale)

Here you can find the source of createSizeFormat(Locale locale)

Description

create Size Format

License

Open Source License

Parameter

Parameter Description
locale a parameter

Declaration

public static NumberFormat createSizeFormat(Locale locale) 

Method Source Code

//package com.java2s;
/* MessageUtils.java//from w  ww  .  ja v  a 2 s  .  c o  m
    
   Copyright (c) 2009 Juergen Schlierf, All Rights Reserved
       
   This file is part of Cubusmail (http://code.google.com/p/cubusmail/).
       
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 3 of the License, or (at your option) any later version.
       
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.
       
   You should have received a copy of the GNU Lesser General Public
   License along with Cubusmail. If not, see <http://www.gnu.org/licenses/>.
       
 */

import java.text.DecimalFormat;
import java.text.NumberFormat;

import java.util.Locale;

public class Main {
    /**
     * @param locale
     * @return
     */
    public static NumberFormat createSizeFormat(Locale locale) {

        NumberFormat sizeFormat = DecimalFormat.getNumberInstance(locale);
        sizeFormat.setGroupingUsed(true);
        sizeFormat.setMaximumFractionDigits(0);
        sizeFormat.setMinimumFractionDigits(0);

        return sizeFormat;
    }
}

Related

  1. BytesToHRSize(String len)
  2. bytesToSizeFormat(long bytes)
  3. bytesToString(long sizeInBytes)
  4. bytesToUnits(long size)
  5. calcSize(double s, String type, int div)
  6. getBytesSpecificationDescription(double sizeInBytes, String formatSpec)
  7. getByteStr(long size)
  8. getDataSize(long size)
  9. getFontSizeInPoints(String fontSizeWithUnit)