This is a sample to get the current date in yyyyMMdd format.
Use SimpleDateFormat. Specify the format in the following format.
import java.text.SimpleDateFormat;
import java.util.Calendar;
Calendar cl = Calendar.getInstance();
//Output the date in the form of yyyyMMdd
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String str = sdf.format(cl.getTime());
System.out.println(str);
//Date yyyy/MM/Output in the form of dd
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/dd");
String str1 = sdf1.format(cl.getTime());
System.out.println(str1);
```
Recommended Posts