Here you can find the source of formatDoubleToFixedLength(String value, int length)
Parameter | Description |
---|---|
value | a parameter |
length | a parameter |
public static final String formatDoubleToFixedLength(String value, int length)
//package com.java2s; //License from project: Apache License public class Main { /**// www. j av a 2 s.c o m * Right justified with 2 decimal places.Procced with zeros? For Revenue * material sale price would be populated format 12.05 to length 12 digits * value = " 12.05" * * @param value * @param length * @return */ public static final String formatDoubleToFixedLength(String value, int length) { String valueStr = value + ""; int diff = length - valueStr.length(); StringBuilder strBuilder = new StringBuilder(); if (diff > 0) { while (diff > 0) { diff--; strBuilder.append(" "); } strBuilder.append(valueStr); valueStr = strBuilder.toString(); } return valueStr; } }