List of usage examples for java.text NumberFormat format
public final String format(long number)
From source file:com.adaptris.core.services.metadata.SimpleSequenceNumberService.java
/** * @see com.adaptris.core.Service#doService(com.adaptris.core.AdaptrisMessage) *///from w w w . j a v a 2 s . co m @Override public void doService(AdaptrisMessage msg) throws ServiceException { NumberFormat formatter = new DecimalFormat(getNumberFormat()); if (!alwaysReplaceMetadata() && msg.containsKey(getMetadataKey())) { log.debug(getMetadataKey() + " already exists, not updating"); return; } try { File myFile = new File(getSequenceNumberFile()); Properties p = load(myFile); long count = Long.parseLong(nextSequenceNumber(p, getMaximumSequenceNumber())); String countString = formatter.format(count); if (countString.length() > getNumberFormat().length()) { count = getBehaviour(getOverflowBehaviour()).wrap(count); countString = formatter.format(count); } incrementSequenceNumberProperty(p, count, getMaximumSequenceNumber()); store(p, myFile); msg.addMetadata(getMetadataKey(), countString); } catch (IOException e) { throw new ServiceException("Failed whilst generating sequence number", e); } }
From source file:com.prowidesoftware.swift.model.field.Field36E.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 2s. c o m*/ */ @Override public String getValueDisplay(int component, Locale locale) { if (component < 1 || component > 4) { throw new IllegalArgumentException("invalid component number " + component + " for field 36E"); } if (locale == null) { locale = Locale.getDefault(); } if (component == 1) { //default format (as is) return getComponent(1); } if (component == 2) { //default format (as is) return getComponent(2); } if (component == 3) { //default format (as is) return getComponent(3); } if (component == 4) { //number or amount java.text.NumberFormat f = java.text.NumberFormat.getNumberInstance(locale); Number n = getComponent4AsNumber(); if (n != null) { return f.format(n); } } return null; }
From source file:com.prowidesoftware.swift.model.field.Field90A.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 2s . com */ @Override public String getValueDisplay(int component, Locale locale) { if (component < 1 || component > 4) { throw new IllegalArgumentException("invalid component number " + component + " for field 90A"); } if (locale == null) { locale = Locale.getDefault(); } if (component == 1) { //default format (as is) return getComponent(1); } if (component == 2) { //default format (as is) return getComponent(2); } if (component == 3) { //default format (as is) return getComponent(3); } if (component == 4) { //number or amount java.text.NumberFormat f = java.text.NumberFormat.getNumberInstance(locale); Number n = getComponent4AsNumber(); if (n != null) { return f.format(n); } } return null; }
From source file:com.prowidesoftware.swift.model.field.Field92R.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 va2s . c om */ @Override public String getValueDisplay(int component, Locale locale) { if (component < 1 || component > 4) { throw new IllegalArgumentException("invalid component number " + component + " for field 92R"); } if (locale == null) { locale = Locale.getDefault(); } if (component == 1) { //default format (as is) return getComponent(1); } if (component == 2) { //default format (as is) return getComponent(2); } if (component == 3) { //default format (as is) return getComponent(3); } if (component == 4) { //number or amount java.text.NumberFormat f = java.text.NumberFormat.getNumberInstance(locale); Number n = getComponent4AsNumber(); if (n != null) { return f.format(n); } } return null; }