在 SimpleDateFormat 中将日期转换为字符串
Converting Date to String in SimpleDateFormat
我想将日期格式转换成字符串,但是字符串输出不出来
DateFormat currentDate = new SimpleDateFormat("dd MM yyyy ");
String currDateString = String.valueOf(currentDate);
System.out.println(currDateString);
要格式化当前日期,您需要创建一个代表当前日期的 Date
实例,然后使用 SimpleDateFormat
将其格式化为字符串。
DateFormat dateFormat = new SimpleDateFormat("dd MM yyyy");
String currDateString = dateFormat.format(new Date());
System.out.println(currDateString);
我想将日期格式转换成字符串,但是字符串输出不出来
DateFormat currentDate = new SimpleDateFormat("dd MM yyyy ");
String currDateString = String.valueOf(currentDate);
System.out.println(currDateString);
要格式化当前日期,您需要创建一个代表当前日期的 Date
实例,然后使用 SimpleDateFormat
将其格式化为字符串。
DateFormat dateFormat = new SimpleDateFormat("dd MM yyyy");
String currDateString = dateFormat.format(new Date());
System.out.println(currDateString);