Here you can find the source of durationToFloat(Duration duration)
public static float durationToFloat(Duration duration)
//package com.java2s; //License from project: BSD License import java.math.BigDecimal; import java.time.Duration; public class Main { public static float durationToFloat(Duration duration) { Float hours = Float.valueOf(duration.toMinutes()) / 60; return round(hours, 2); }/*from w w w.jav a 2 s .c o m*/ public static float round(float d, int decimalPlace) { BigDecimal bd = new BigDecimal(Float.toString(d)); bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP); return bd.floatValue(); } }