Example usage for java.text NumberFormat format

List of usage examples for java.text NumberFormat format

Introduction

In this page you can find the example usage for java.text NumberFormat format.

Prototype

public final String format(long number) 

Source Link

Document

Specialization of format.

Usage

From source file:com.prowidesoftware.swift.model.field.Field243.java

/**
 * Returns a localized suitable for showing to humans string of a field component.<br>
 *
 * @param component number of the component to display
 * @param locale optional locale to format date and amounts, if null, the default locale is used
 * @return formatted component value or null if component number is invalid or not present
 * @throws IllegalArgumentException if component number is invalid for the field
 * @since 7.8//w  ww.  ja  v  a  2 s  .  c o m
 */
@Override
public String getValueDisplay(int component, Locale locale) {
    if (component < 1 || component > 1) {
        throw new IllegalArgumentException("invalid component number " + component + " for field 243");
    }
    if (locale == null) {
        locale = Locale.getDefault();
    }
    if (component == 1) {
        //number or amount
        java.text.NumberFormat f = java.text.NumberFormat.getNumberInstance(locale);
        Number n = getComponent1AsNumber();
        if (n != null) {
            return f.format(n);
        }
    }
    return null;
}

From source file:com.prowidesoftware.swift.model.field.Field26E.java

/**
 * Returns a localized suitable for showing to humans string of a field component.<br>
 *
 * @param component number of the component to display
 * @param locale optional locale to format date and amounts, if null, the default locale is used
 * @return formatted component value or null if component number is invalid or not present
 * @throws IllegalArgumentException if component number is invalid for the field
 * @since 7.8/*from w ww  . j a v  a2s  . c o  m*/
 */
@Override
public String getValueDisplay(int component, Locale locale) {
    if (component < 1 || component > 1) {
        throw new IllegalArgumentException("invalid component number " + component + " for field 26E");
    }
    if (locale == null) {
        locale = Locale.getDefault();
    }
    if (component == 1) {
        //number or amount
        java.text.NumberFormat f = java.text.NumberFormat.getNumberInstance(locale);
        Number n = getComponent1AsNumber();
        if (n != null) {
            return f.format(n);
        }
    }
    return null;
}

From source file:com.prowidesoftware.swift.model.field.Field313.java

/**
 * Returns a localized suitable for showing to humans string of a field component.<br>
 *
 * @param component number of the component to display
 * @param locale optional locale to format date and amounts, if null, the default locale is used
 * @return formatted component value or null if component number is invalid or not present
 * @throws IllegalArgumentException if component number is invalid for the field
 * @since 7.8/*from   w  w w. j a va 2 s  .c om*/
 */
@Override
public String getValueDisplay(int component, Locale locale) {
    if (component < 1 || component > 1) {
        throw new IllegalArgumentException("invalid component number " + component + " for field 313");
    }
    if (locale == null) {
        locale = Locale.getDefault();
    }
    if (component == 1) {
        //number or amount
        java.text.NumberFormat f = java.text.NumberFormat.getNumberInstance(locale);
        Number n = getComponent1AsNumber();
        if (n != null) {
            return f.format(n);
        }
    }
    return null;
}

From source file:com.prowidesoftware.swift.model.field.Field38A.java

/**
 * Returns a localized suitable for showing to humans string of a field component.<br>
 *
 * @param component number of the component to display
 * @param locale optional locale to format date and amounts, if null, the default locale is used
 * @return formatted component value or null if component number is invalid or not present
 * @throws IllegalArgumentException if component number is invalid for the field
 * @since 7.8//  w  w w  .  ja  v a2 s  .c  om
 */
@Override
public String getValueDisplay(int component, Locale locale) {
    if (component < 1 || component > 1) {
        throw new IllegalArgumentException("invalid component number " + component + " for field 38A");
    }
    if (locale == null) {
        locale = Locale.getDefault();
    }
    if (component == 1) {
        //number or amount
        java.text.NumberFormat f = java.text.NumberFormat.getNumberInstance(locale);
        Number n = getComponent1AsNumber();
        if (n != null) {
            return f.format(n);
        }
    }
    return null;
}

From source file:com.prowidesoftware.swift.model.field.Field38D.java

/**
 * Returns a localized suitable for showing to humans string of a field component.<br>
 *
 * @param component number of the component to display
 * @param locale optional locale to format date and amounts, if null, the default locale is used
 * @return formatted component value or null if component number is invalid or not present
 * @throws IllegalArgumentException if component number is invalid for the field
 * @since 7.8//from   w  w  w  .  j  a v  a 2s.c o  m
 */
@Override
public String getValueDisplay(int component, Locale locale) {
    if (component < 1 || component > 1) {
        throw new IllegalArgumentException("invalid component number " + component + " for field 38D");
    }
    if (locale == null) {
        locale = Locale.getDefault();
    }
    if (component == 1) {
        //number or amount
        java.text.NumberFormat f = java.text.NumberFormat.getNumberInstance(locale);
        Number n = getComponent1AsNumber();
        if (n != null) {
            return f.format(n);
        }
    }
    return null;
}

From source file:com.prowidesoftware.swift.model.field.Field401.java

/**
 * Returns a localized suitable for showing to humans string of a field component.<br>
 *
 * @param component number of the component to display
 * @param locale optional locale to format date and amounts, if null, the default locale is used
 * @return formatted component value or null if component number is invalid or not present
 * @throws IllegalArgumentException if component number is invalid for the field
 * @since 7.8// ww w. j a v a  2 s . c  o  m
 */
@Override
public String getValueDisplay(int component, Locale locale) {
    if (component < 1 || component > 1) {
        throw new IllegalArgumentException("invalid component number " + component + " for field 401");
    }
    if (locale == null) {
        locale = Locale.getDefault();
    }
    if (component == 1) {
        //number or amount
        java.text.NumberFormat f = java.text.NumberFormat.getNumberInstance(locale);
        Number n = getComponent1AsNumber();
        if (n != null) {
            return f.format(n);
        }
    }
    return null;
}

From source file:com.prowidesoftware.swift.model.field.Field431.java

/**
 * Returns a localized suitable for showing to humans string of a field component.<br>
 *
 * @param component number of the component to display
 * @param locale optional locale to format date and amounts, if null, the default locale is used
 * @return formatted component value or null if component number is invalid or not present
 * @throws IllegalArgumentException if component number is invalid for the field
 * @since 7.8/*from  w  w  w.  j ava 2s .co m*/
 */
@Override
public String getValueDisplay(int component, Locale locale) {
    if (component < 1 || component > 1) {
        throw new IllegalArgumentException("invalid component number " + component + " for field 431");
    }
    if (locale == null) {
        locale = Locale.getDefault();
    }
    if (component == 1) {
        //number or amount
        java.text.NumberFormat f = java.text.NumberFormat.getNumberInstance(locale);
        Number n = getComponent1AsNumber();
        if (n != null) {
            return f.format(n);
        }
    }
    return null;
}

From source file:com.prowidesoftware.swift.model.field.Field26J.java

/**
 * Returns a localized suitable for showing to humans string of a field component.<br>
 *
 * @param component number of the component to display
 * @param locale optional locale to format date and amounts, if null, the default locale is used
 * @return formatted component value or null if component number is invalid or not present
 * @throws IllegalArgumentException if component number is invalid for the field
 * @since 7.8/*from w w w  .  j av a2 s.  co m*/
 */
@Override
public String getValueDisplay(int component, Locale locale) {
    if (component < 1 || component > 1) {
        throw new IllegalArgumentException("invalid component number " + component + " for field 26J");
    }
    if (locale == null) {
        locale = Locale.getDefault();
    }
    if (component == 1) {
        //number or amount
        java.text.NumberFormat f = java.text.NumberFormat.getNumberInstance(locale);
        Number n = getComponent1AsNumber();
        if (n != null) {
            return f.format(n);
        }
    }
    return null;
}

From source file:com.prowidesoftware.swift.model.field.Field26L.java

/**
 * Returns a localized suitable for showing to humans string of a field component.<br>
 *
 * @param component number of the component to display
 * @param locale optional locale to format date and amounts, if null, the default locale is used
 * @return formatted component value or null if component number is invalid or not present
 * @throws IllegalArgumentException if component number is invalid for the field
 * @since 7.8/*w w  w  . j a v  a 2 s .c om*/
 */
@Override
public String getValueDisplay(int component, Locale locale) {
    if (component < 1 || component > 1) {
        throw new IllegalArgumentException("invalid component number " + component + " for field 26L");
    }
    if (locale == null) {
        locale = Locale.getDefault();
    }
    if (component == 1) {
        //number or amount
        java.text.NumberFormat f = java.text.NumberFormat.getNumberInstance(locale);
        Number n = getComponent1AsNumber();
        if (n != null) {
            return f.format(n);
        }
    }
    return null;
}

From source file:adalid.util.meta.sql.MetaFolderSql.java

public MetaFolderSql(String path) {
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMinimumFractionDigits(1);/*from www  .j  a va2s  .  com*/
    nf.setMaximumFractionDigits(2);
    logger.info("max-file-size=" + nf.format(MAX_FILE_SIZE_MEGAS) + "MB");
    rootFolder = PropertiesHandler.getRootFolder();
    if (rootFolder == null) {
        throw new RuntimeException("root folder is missing or invalid");
    }
    rootFolderPath = Paths.get(rootFolder.getPath());
    logger.info("root-folder=" + rootFolderPath);
    if (path == null) {
        throw new IllegalArgumentException("null folder path");
    } else {
        File file = new File(path);
        if (file.isAbsolute()) {
            metaFolder = file;
        } else {
            metaFolder = new File(rootFolder.getAbsolutePath(), path);
        }
    }
    metaFolderPath = Paths.get(metaFolder.getPath());
    logger.info("meta-folder=" + metaFolderPath);
    if (metaFolder.isDirectory()) {
        if (metaFolder.isHidden()) {
            throw new IllegalArgumentException(metaFolderPath + " is a hidden directory");
        }
    } else {
        throw new IllegalArgumentException(metaFolderPath + " is not a directory");
    }
    baseFolder = metaFolder.getParentFile();
    baseFolderPath = Paths.get(baseFolder.getPath());
    logger.info("base-folder=" + baseFolderPath);
    files = new TreeMap<>();
    folders = new TreeMap<>();
    fileTypes = new TreeMap<>();
    metaFolderWrapper = new FolderWrapper(metaFolder);
    folders.put(getRelativeToBasePath(metaFolder), metaFolderWrapper);
}