Java tutorial
//package com.java2s; import java.math.BigDecimal; public class Main { public static float getDurationToFloat(long duration) { float f = 0; try { BigDecimal b = new BigDecimal(Long.toString(duration)); BigDecimal one = new BigDecimal("1000"); f = b.divide(one, 1, BigDecimal.ROUND_HALF_UP).floatValue(); } catch (Exception e) { e.printStackTrace(); f = 0; } return f; } }