Java tutorial
//package com.java2s; public class Main { /** * * @param d eot in hours * @return formatted string */ public final static String eotToString(double d) { int m = (int) Math.floor(Math.abs(d) * 60d); int s = (int) Math.round((3600d * Math.abs(d)) - (m * 60d)); return ((d > 0 ? "+" : "-") + Integer.toString(m) + "m" + Integer.toString(s) + "s"); } }