Exactly on December 31 (today), showing January 1 (tomorrow), January 2 (the day After Tomorrow), 2014 years later, welcomed the 2015.I wish you a happy New Year!
Import Java.io.file;import Java.util.calendar;import Java.util.timezone;public class Test {public static void main ( String[] (args) {test test =new Test (); Test.printday ( -1); test.printday (0); Test.printday (1); Test.printday (2); Test.printday (3);} private void Printday (int tempsingle) {Calendar calendar =calendar.getinstance (); Calendar.add (Calendar.day_of_year, Tempsingle); SetTime (Calendar.gettimeinmillis ()); System.out.println (Getformattimenear3day ());} Private long timemills;public void settime (Long timemills) {this.timemills = Timemills;} Public long GetTime () {return timemills;} Public String Getformattime () {return new DateTime (GetTime ()). Getstringdateweek (Datetime.format_md_hour_minute_week );} Public String Getformattimeonlyweek () {return new DateTime (GetTime ()). Getstringdateweek (Datetime.format_md_hour_ Only_week);} Public String Getformattimenear3day () {String timetext = ""; Calendar calendar= calendar.getinstance (Timezone.gettimezone ("gmt+08:00")); int cyear = Calendar.get (Calendar.YEAR); int Ctoday = Calendar.get (calendar.day_of_year); int ctotalday = Calendar.getmaximum (calendar.day_of_year); Calendar.settimeinmillis (GetTime ()); int year = Calendar.get (calendar.year), int day = Calendar.get (calendar.day_of_ Switch (year-cyear) {case-1:default:timetext = Getnear3day (2,8); Break;case 0:timetext = Getnear3day (day,ctoday) ; break;case 1:int vday = day+ (ctotalday-ctoday) -1;timetext = Getnear3day (day+vday,day); break;} return timetext;} Public String getnear3day (int day,int ctoday) {String timetext= "", switch (day-ctoday) {case 0:timetext= "today"; timetext + = Getformattimeonlyweek (); Break;case 1:timetext = "Tomorrow"; timetext + = Getformattimeonlyweek (); Break;case 2:timeText = "Day After Tomorrow"; Timetext + = Getformattimeonlyweek (); break;default:timetext = Getformattime (); break;} return timetext;}}
Java: Today, tomorrow, the state of the day acquired, cross-year