简体   繁体   中英

Android:Timestamp is not displaying device time

Hi I need to display the timestamp but i didn't get the proper output here is my coding can you check my code and correct my mistakes.My code displays only UTC time not device time.

// show dateTime

        viewHolder.dateTime.setVisibility(View.VISIBLE);
        DateTime createdAt = message.getCreatedAt();
        LBLog.v(TAG, "createdAt = " + createdAt.toString());
        LBLog.v(TAG, "createdAtMillis = "  + createdAt.getMillis());
        DateTimeFormatter fmtTimeBubble = DateTimeFormat.forPattern(LBUtil.TIME_AM_PM_FORMAT);
        viewHolder.dateTime.setText(fmtTimeBubble.print(createdAt));
    }

    // update divider here
    DateTimeFormatter fmt = DateTimeFormat.forPattern(LBUtil.MONTH_DD_YEAR_FORMAT);
    DateTime dividerDateTime = message.getCreatedAt();
    viewHolder.dividerTextView.setText(fmt.print(dividerDateTime));

Please check this I need a timestamp like this: image link

I think you never set the TimeZone.Set the Timezone first then run Hope it useful for you.

    //gets the default TimeZone

    DateTimeZone dateTimeZone= DateTimeZone.getDefault();

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