Home > Back-end >  Time transformation with decimal point
Time transformation with decimal point

Time:11-12

Customer interface to get the time format is a decimal, 44114.6743753588, for example, how to use Java into a normal date, such as: yyyy - MM - dd HH: MM: ss

CodePudding user response:

That you want to know how it is converted to decimal format, and, in turn, turn to

CodePudding user response:

In Delphi, TDateTime=type Double, so can do type conversion can directly, see the Delphi under transformation, so to turn in Java:
 

Public static Date doubleToDate (Double dateTime) {
The Calendar base=Calendar. GetInstance ();
//the date of the Delphi type since the 1899-12-30
Base. The set (1899, 11, 30, 0, 0, 0).
Base. The add (Calendar. The DATE and dateTime intValue ());
Base. The add (Calendar. MILLISECOND, (int) (dateTime (% 1) * 24 * 60 * 60 * 1000));
Return to base. GetTime ();
}

Public static void main (String [] args) {
System. The out. Println (doubleToDate (44114.6743753588));
}

Output: the Sat Oct 10 16:11:06 CST 2020
  • Related