Calendar LocalDateTimeを使用する
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Calendar calendar = Calendar.getInstance();
Log.d("Calendar",calendar.getTime().toString());
// Fri Feb 21 10:29:43 GMT+09:00 2020
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Log.d("Calendar Format",sdf.format(calendar.getTime()));
// 2020-02-21
LocalDateTime ldt = LocalDateTime.now();
Log.d("LocalDateTime",ldt.toString());
// 2020-02-21T10:29:43.372
DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-/MM/dd");
Log.d("LocalDateTime Format",ldt.format(f));
// 2020-/02/21
現在の日時のタイムスタンプを取得する
Timestamp timestamp1 = new Timestamp(System.currentTimeMillis());
// または
Timestamp timestamp2 = new Timestamp(new Date())