Here you can find the source of intToStr(int priceInt)
public static String intToStr(int priceInt)
//package com.java2s; //License from project: Apache License public class Main { public static String intToStr(int priceInt) { boolean isPositivenumber = true; if (priceInt <= 0) { priceInt = Math.abs(priceInt); isPositivenumber = false;// ww w.j a va2s. co m } if (priceInt == 0) { return "0.00"; } String priceStr = priceInt + ""; String data1 = ""; String data2 = ""; int length = priceStr.length(); if (length >= 3) { data1 = priceStr.substring(0, length - 2); data2 = priceStr.substring(length - 2, length); } if (length == 2) { data1 = "0"; data2 = priceStr; } if (length == 1) { data1 = "0"; data2 = "0" + priceStr; } priceStr = data1 + "." + data2; if (!isPositivenumber) { priceStr = "-" + priceStr; } return priceStr; } }