Try the following:
public static void main(String[] args) throws Exception { DateFormat format = new SimpleDateFormat("HH:mm:ss a"); format.setTimeZone(TimeZone.getTimeZone("UTC")); for(String fracStr : args) { double frac = Double.parseDouble(fracStr); long day = (long) Math.floor(frac); frac = frac - day; Date time = new Date((long) ( 86400000l * frac)); System.out.println(fracStr+" -> "+format.format(time)); } }
A quick note here - GMT time zone may not give you the expected results, but UTC will be. This is because Java views GMT as a valid abbreviation for Europe / London, and between 1968 and 1972, London was in constant summer light. So, midnight January 1, 1970 (Java era) is also 1:00 January 1, 1970 (GMT).
source share