Java_Android 日期转字符串 字符串转日期

⌚Time: 2022-10-31 17:32:41

👨‍💻Author: Jack Ge

日期转字符串


SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd  hh:mm:ss");

Date dates = new Date();

String strTime = sdf.format(dates);

EditText editDate = findViewById(R.id.editText6);

editDate.setText(strTime);

字符串转日期


SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd  hh:mm:ss");

Date date = sdf.parse( " 2010-07-10 19:20:00 " );