Here you can find the source of formatDoubleWithPadding(String value, int length, char pad)
Parameter | Description |
---|---|
value | a parameter |
length | a parameter |
pad | a parameter |
public static final String formatDoubleWithPadding(String value, int length, char pad)
//package com.java2s; //License from project: Apache License public class Main { /**//from ww w.j a v a 2 s. c o m * The total amount in 2 decimal places without decimal point with a leading * zero.ie 12.00 = 1200 value = 000000146560 * * @param value * @param length * @param pad * @return */ public static final String formatDoubleWithPadding(String value, int length, char pad) { String valueStr = value + ""; int diff = length - valueStr.length(); StringBuilder strBuilder = new StringBuilder(); if (diff > 0) { while (diff > -1) { diff--; strBuilder.append(pad); } strBuilder.append(valueStr); valueStr = strBuilder.toString(); valueStr = valueStr.substring(0, valueStr.indexOf('.')) + valueStr.substring(valueStr.indexOf('.') + 1, valueStr.length()); } return valueStr; } }