简体   繁体   中英

Time segment lost when I try to retrieve Date and time from SQL Database

来自mssql的数据

This is what the Datetime data look like in the database

when I try to retrieve the data in my Android app, I use the following code

 DateTime createDateTime = new DateTime(dataset.getDate("createDateTime"));

Log.d("Time I get is",createDateTime.toString());

at the end it only manage to return

2015-12-16T00:00:00.000+08:00

in my datalog, my time become 00:00

How can I retrieve the time too?

Please help

try using SimpleDateFormat:

SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
String dateTime = sdf.format(dataset.getDate("createDateTime"));
Log.d("Time I get is", dateTime);

You can also try:

dataset.getTimestamp("createDateTime");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM