Java examples for java.lang:double Format
This method is used to convert a dollar amount to cents given String as input and returns a long value
//package com.java2s; public class Main { /**//from w w w .j a va2s . c om * This method is used to convert a dollar amount to cents given String as * input and returns a long value * * @param amount * @return */ public static long dollarToCentsRtnLong(String amount) { double doubleVal = Double.parseDouble(amount); long longVal = (long) (doubleVal * 100); return ((Long) longVal); } }