class="java" name="code"> public static void main(String[] args) { int days = 41829; double ditNumber = 0.4330324074; Date date = getDate(days); Date dateTime = getTime(date, ditNumber); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); System.out.println(sdf.format(dateTime)); } public static Date getDate(int days) { Calendar c = Calendar.getInstance(); c.set(1900, 0, 1); c.add(Calendar.DATE, days - 2); return c.getTime(); } public static Date getTime(Date date, double ditNumber) { Calendar c = Calendar.getInstance(); int mills = (int) (Math.round(ditNumber * 24 * 3600)); int hour = mills / 3600; int minute = (mills - hour * 3600) / 60; int second = mills - hour * 3600 - minute * 60; c.setTime(date); c.set(Calendar.HOUR_OF_DAY, hour); c.set(Calendar.MINUTE, minute); c.set(Calendar.SECOND, second); return c.getTime(); }
?