Since there is a need in the business to send a new employee three months to the positive when the mail, so write a small example to see the effect
Time is long in the entity class, so the thought is to turn out date first, use calender to calculate plus 75 days before turning to string display
Pasting
Public static voidMain(String args[]) {
SimpleDateFormat SDF =NewSimpleDateFormat ("Yyyy-mm-dd");
Longlongtime =NewDate (). GetTime ();
System. out. println ("Long is:"+ longtime);
System. out. println ("Long is converted to date:");
System. out. println ("Longtodate:"+NewSimpleDateFormat ("Yyyy-mm-dd"). Format (NewDate (longtime)));
Calendar Calendar = Calendar.getinstance();
Calendar.settime (NewDate (longtime));
Calendar.add (Calendar.Day_of_month, + the);
System. out. println ("75 days later:"+ Sdf.format (Calendar.gettime (). GetTime ()));
}
The test results are as followsLong converted to date:
Longtodate:2018-06-16
After 75 days: 2018-08-30
Time calculation problems in Java