gpt4 book ai didi

java - 从检索到的日期中提取日期-月份-年份

转载 作者:搜寻专家 更新时间:2023-11-01 08:03:30 35 4
gpt4 key购买 nike

我正在获取系统当前日期并尝试在 TextView 中显示它。

尝试下面的代码后

private OnClickListener listener1 = new OnClickListener() {

@Override
public void onClick(View arg0) {
long dtMili = System.currentTimeMillis();
Date dt = new Date(dtMili);
gett.setText(dt.toString());

}
};

我得到的是

enter image description here

但我只想要类似 15/7/2013 的东西。

最佳答案

我想你需要这个:

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
String date = sdf.format(dt);

另见 Customizing Formats .

关于java - 从检索到的日期中提取日期-月份-年份,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17648885/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com