Java Date format to String like "2020/12/31"
import android.annotation.SuppressLint; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void main(String[] argv) throws Exception { System.out.println(getCurrentDate()); }//from ww w . j a va 2 s .c om @SuppressLint("SimpleDateFormat") public static Date getCurrentDate() throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); String date = sdf.format(new Date()); return sdf.parse(date); } }