Import Java. text. parseexception; import Java. text. simpledateformat; import Java. util. calendar; import Java. util. date; public class dateutil {public static void main (string [] ARGs) {date = new date (); simpledateformat SDF = new simpledateformat ("yyyy-mm-dd "); string specifiedday = SDF. format (date); system. out. println (getspecifieddaybefore (specifiedday); system. out. println (getspecifieddayafter (specifiedday);}/*** get the day before the specified date ** @ Param specifiedday * @ return * @ throws exception */public static string getspecifieddaybefore (string specifiedday) {// you can use new date (). tolocalstring () passed the parameter calendar c = calendar. getinstance (); Date = NULL; try {date = new simpledateformat ("YY-mm-dd "). parse (specifiedday);} catch (parseexception e) {e. printstacktrace ();} C. settime (date); int day = C. get (calendar. date); C. set (calendar. date, day-1); string daybefore = new simpledateformat ("yyyy-mm-dd "). format (C. gettime (); Return daybefore;}/*** get the day after the specified date ** @ Param specifiedday * @ return */public static string getspecifieddayafter (string specifiedday) {calendar c = calendar. getinstance (); Date = NULL; try {date = new simpledateformat ("YY-mm-dd "). parse (specifiedday);} catch (parseexception e) {e. printstacktrace ();} C. settime (date); int day = C. get (calendar. date); C. set (calendar. date, day + 1); string dayafter = new simpledateformat ("yyyy-mm-dd "). format (C. gettime (); Return dayafter ;}}