在Android的INT转换为日期格式DD / MM / YYYY [英] Convert int to date format dd / MM / yyyy in Android

查看:220
本文介绍了在Android的INT转换为日期格式DD / MM / YYYY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发中,我需要得到的最后一个短信发送的应用程序。所有的好,所以我就知道装运日期。以EX pression INT cursor.getColumnIndex indexDate =(DATE)我得到一个整数,但我需要转换的日期ESES整数格式DD / MM / YYYY,然后将其转换日期为String。我会怎么做?先谢谢了。

I am developing an application in which I need to get the last sent SMS. All good so I'll know the date of shipment. With the expression int cursor.getColumnIndex indexDate = (DATE) I get an integer but I need to convert a date eses integer format dd / MM / yyyy and then convert that date to String. How I would do?. Thanks in advance.

推荐答案

试试这个:

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的INT转换为日期格式DD / MM / YYYY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆