Home > Back-end >  How to calculate milliseconds masters
How to calculate milliseconds masters

Time:09-22

Long day=date/(60 * 60 * 24);
Long hour=(date/(60 * 60) - day * 24);
Long min=((date/60) - day 60 - hour * * 24 * 60);
Long s=(date - day 60 - hour * * 24 * 60 * 60 * 60 * 60 min);
String strtime="remaining:" + + "day" + hour day + + min "hour" + "points" + s + "seconds"; ,

Can    I don't know how to make

CodePudding user response:

Only day hour and minute, second, how to write ms?

CodePudding user response:

The date is come from?

CodePudding user response:

The
refer to the original poster qq_40488391 response:
long day=date/(60 * 60 * 24);
Long hour=(date/(60 * 60) - day * 24);
Long min=((date/60) - day 60 - hour * * 24 * 60);
Long s=(date - day 60 - hour * * 24 * 60 * 60 * 60 * 60 min);
String strtime="remaining:" + + "day" + hour day + + min "hour" + "points" + s + "seconds"; ,

Can I make it


How do you to this date, whether itself contains milliseconds,

CodePudding user response:

No: just write 0
Have read with a millisecond value time method

CodePudding user response:

1 second is equal to 1000 milliseconds, isn't it, continue to lose,

CodePudding user response:

Or use the Calendar object, put your time into the Calendar, and then through the Calendar object take
Calendar CLD=Calendar. GetInstance ();
CLD. SetTime (date);
CLD. Get (Calendar. MILLISECOND)

CodePudding user response:

The
refer to the original poster qq_40488391 response:
long day=date/(60 * 60 * 24);
Long hour=(date/(60 * 60) - day * 24);
Long min=((date/60) - day 60 - hour * * 24 * 60);
Long s=(date - day 60 - hour * * 24 * 60 * 60 * 60 * 60 min);
String strtime="remaining:" + + "day" + hour day + + min "hour" + "points" + s + "seconds"; ,

Can I make it


If the Date is a Java class, itself is with ms, you the above algorithm is wrong,

CodePudding user response:

In addition to using/operations, will learn to apply % operation
Long day=date/(1000 * 60 * 60 * 24);
Long hour=(date/(1000 * 60 * 60)) % 24;
Long min=(date/(1000 * 60)) % 60;
Long s=(date/1000) % 60;
Long ms=date % 1000;
  • Related