可以使用以下代码获取当前日期并将其转换为字符串:

import java.text.SimpleDateFormat;
import java.util.Date;

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String currentDate = dateFormat.format(new Date());

这里使用了 SimpleDateFormat 类来将日期转换为字符串。构造函数中的参数 "yyyy-MM-dd" 表示输出的日期格式为年-月-日。format() 方法将 Date 类型的日期转换为字符串类型。最后得到的 currentDate 就是当前日期的字符串表示形式。

android 获取当前日期 转换成字符串

原文地址: http://www.cveoy.top/t/topic/eQTM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录