Question

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

Was it helpful?

Solution

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();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top