簡體   English   中英

Android:時間戳記未顯示設備時間

[英]Android:Timestamp is not displaying device time

嗨,我需要顯示時間戳,但是我沒有得到正確的輸出,這是我的編碼可以檢查我的代碼並更正我的錯誤嗎。我的代碼僅顯示UTC時間而不顯示設備時間。

// 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));

請檢查一下,我需要這樣的時間戳: 圖片鏈接

我認為您從未設置過TimeZone,請先設置時區然后運行希望它對您有用。

    //gets the default TimeZone

    DateTimeZone dateTimeZone= DateTimeZone.getDefault();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM