gpt4 book ai didi

android - 在 Android 中将 int 转换为日期格式 dd/MM/yyyy

转载 作者:行者123 更新时间:2023-11-29 14:32:02 24 4
gpt4 key购买 nike

我正在开发一个应用程序,我需要在其中获取最后发送的短信。一切都很好,所以我知道发货日期。使用表达式 int cursor.getColumnIndex indexDate = (DATE) 我得到一个整数,但我需要转换日期 eses 整数格式 dd/MM/yyyy,然后将该日期转换为字符串。我会怎么做?提前致谢。

最佳答案

试试这个:

int dateColumn = cursor.getColumnIndex("date"); //integer represent date you get from db
Date d = new Date(Long.parseLong(cursor.getString(dateColumn)));
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd " + "\n" + "hh:mm:ss");
String date = dateFormat.format(d); // formatted date in string

关于android - 在 Android 中将 int 转换为日期格式 dd/MM/yyyy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20389811/

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