1. SimpleDateFormat f4 = new SimpleDateFormat("Today is"+"yyyy year MM month dd day E kk dot mm minute");//Different date formats can be displayed according to different style requests
System.out.println(f4.format(new date()));
The date format output by the code is: the current time is 16:46 on March 22, 2016
2. The time format only displays the year, month and day:
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//Set the date format
Date d=sdf.parse(newstime);
String str=df.format(d);
System.out.println(str); // output format yyyy-mm-dd
3. Add one day after today's time:
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//Set the date format
Date date= (new Date());
Calendar c = Calendar.getInstance ();
c.setTime(date); //Set the current date
c.add(Calendar.DATE, 1); //Add 1 day to the
date -1 to subtract one day date = c.getTime();
String str=df. format(date);
System.out.println(str); // output format yyyy-MM-dd HH:mm:ss
System.out.println(f4.format(new date()));
The date format of the code output is: the current time is 16:46 on March 22, 2016
The date format of the code output is: the current time is 16:46 on March 22, 2016