Skip to content

Instantly share code, notes, and snippets.

@ericksli
Last active June 11, 2019 03:52
Show Gist options
  • Save ericksli/1a7383749c6a32539b96eda2ef655c40 to your computer and use it in GitHub Desktop.
Save ericksli/1a7383749c6a32539b96eda2ef655c40 to your computer and use it in GitHub Desktop.
Android default date and time formats

Android Default Date and Time Formats

Sample Timestamps

Name Timestamp (millisecond) Human-readable form
Timestamp A 1557086889000 Monday, 6 May 2019 04:08:09 GMT+08:00
Timestamp B 1571984435000 Friday, 25 October 2019 14:20:35 GMT+08:00

12-hour Format

System Default - SHORT

Locale Style Formatted Timestamp A (Date) Formatted Timestamp A (Time) Formatted Timestamp B (Date) Formatted Timestamp B (Time)
en-rHK SHORT 6/5/2019 4:08 AM 25/10/2019 2:20 PM
en-rID SHORT 5/6/19 4:08 AM 10/25/19 2:20 PM
en-rIN SHORT 06/05/19 4:08 AM 25/10/19 2:20 PM
en-rMY SHORT 06/05/2019 4:08 AM 25/10/2019 2:20 PM
en-rPH SHORT 06/05/2019 4:08 AM 25/10/2019 2:20 PM
en-rSG SHORT 6/5/19 4:08 AM 25/10/19 2:20 PM
en-rTH SHORT 5/6/19 4:08 AM 10/25/19 2:20 PM
en-rUS SHORT 5/6/19 4:08 AM 10/25/19 2:20 PM
en-rVN SHORT 5/6/19 4:08 AM 10/25/19 2:20 PM
hi-rIN SHORT 6/5/19 4:08 am 25/10/19 2:20 pm
in-rID SHORT 06/05/19 4.08 AM 25/10/19 2.20 PM
ms-rMY SHORT 6/05/19 4:08 PG 25/10/19 2:20 PTG
th-rTH SHORT 6/5/19 4:08 ก่อนเที่ยง 25/10/19 2:20 หลังเที่ยง
vi-rVN SHORT 06/05/2019 4:08 SA 25/10/2019 2:20 CH
zh-rHK SHORT 6/5/2019 上午4:08 25/10/2019 下午2:20
zh-rTW SHORT 2019/5/6 上午4:08 2019/10/25 下午2:20

System Default - MEDIUM

Locale Style Formatted Timestamp A (Date) Formatted Timestamp A (Time) Formatted Timestamp B (Date) Formatted Timestamp B (Time)
en-rHK MEDIUM 6 May 2019 4:08:09 AM 25 Oct 2019 2:20:35 PM
en-rID MEDIUM May 6, 2019 4:08:09 AM Oct 25, 2019 2:20:35 PM
en-rIN MEDIUM 06-May-2019 4:08:09 AM 25-Oct-2019 2:20:35 PM
en-rMY MEDIUM 6 May 2019 4:08:09 AM 25 Oct 2019 2:20:35 PM
en-rPH MEDIUM 6 May 2019 4:08:09 AM 25 Oct 2019 2:20:35 PM
en-rSG MEDIUM 6 May 2019 4:08:09 AM 25 Oct 2019 2:20:35 PM
en-rTH MEDIUM May 6, 2019 4:08:09 AM Oct 25, 2019 2:20:35 PM
en-rUS MEDIUM May 6, 2019 4:08:09 AM Oct 25, 2019 2:20:35 PM
en-rVN MEDIUM May 6, 2019 4:08:09 AM Oct 25, 2019 2:20:35 PM
hi-rIN MEDIUM 06/05/2019 4:08:09 am 25/10/2019 2:20:35 pm
in-rID MEDIUM 6 Mei 2019 4.08.09 AM 25 Okt 2019 2.20.35 PM
ms-rMY MEDIUM 6 Mei 2019 4:08:09 PG 25 Okt 2019 2:20:35 PTG
th-rTH MEDIUM 6 พ.ค. 2019 4:08:09 ก่อนเที่ยง 25 ต.ค. 2019 2:20:35 หลังเที่ยง
vi-rVN MEDIUM 6 thg 5, 2019 4:08:09 SA 25 thg 10, 2019 2:20:35 CH
zh-rHK MEDIUM 2019年5月6日 上午4:08:09 2019年10月25日 下午2:20:35
zh-rTW MEDIUM 2019年5月6日 上午4:08:09 2019年10月25日 下午2:20:35

System Default - LONG

Locale Style Formatted Timestamp A (Date) Formatted Timestamp A (Time) Formatted Timestamp B (Date) Formatted Timestamp B (Time)
en-rHK LONG 6 May 2019 4:08:09 AM HKT 25 October 2019 2:20:35 PM HKT
en-rID LONG May 6, 2019 4:08:09 AM GMT+08:00 October 25, 2019 2:20:35 PM GMT+08:00
en-rIN LONG 6 May 2019 4:08:09 AM GMT+08:00 25 October 2019 2:20:35 PM GMT+08:00
en-rMY LONG 6 May 2019 4:08:09 AM GMT+08:00 25 October 2019 2:20:35 PM GMT+08:00
en-rPH LONG 6 May 2019 4:08:09 AM GMT+08:00 25 October 2019 2:20:35 PM GMT+08:00
en-rSG LONG 6 May 2019 4:08:09 AM GMT+08:00 25 October 2019 2:20:35 PM GMT+08:00
en-rTH LONG May 6, 2019 4:08:09 AM GMT+08:00 October 25, 2019 2:20:35 PM GMT+08:00
en-rUS LONG May 6, 2019 4:08:09 AM GMT+08:00 October 25, 2019 2:20:35 PM GMT+08:00
en-rVN LONG May 6, 2019 4:08:09 AM GMT+08:00 October 25, 2019 2:20:35 PM GMT+08:00
hi-rIN LONG 6 मई 2019 4:08:09 am GMT+08:00 25 अक्तूबर 2019 2:20:35 pm GMT+08:00
in-rID LONG 6 Mei 2019 04.08.09 GMT+08:00 25 Oktober 2019 14.20.35 GMT+08:00
ms-rMY LONG 6 Mei 2019 4:08:09 PG GMT+08:00 25 Oktober 2019 2:20:35 PTG GMT+08:00
th-rTH LONG 6 พฤษภาคม ค.ศ. 2019 4 นาฬิกา 08 นาที 09 วินาที GMT+08:00 25 ตุลาคม ค.ศ. 2019 14 นาฬิกา 20 นาที 35 วินาที GMT+08:00
vi-rVN LONG 6 tháng 5, 2019 04:08:09 GMT+08:00 25 tháng 10, 2019 14:20:35 GMT+08:00
zh-rHK LONG 2019年5月6日 上午4:08:09 [GMT+08:00] 2019年10月25日 下午2:20:35 [GMT+08:00]
zh-rTW LONG 2019年5月6日 上午4:08:09 [GMT+08:00] 2019年10月25日 下午2:20:35 [GMT+08:00]

System Default - FULL

Locale Style Formatted Timestamp A (Date) Formatted Timestamp A (Time) Formatted Timestamp B (Date) Formatted Timestamp B (Time)
en-rHK FULL Monday, 6 May 2019 4:08:09 AM Hong Kong Standard Time Friday, 25 October 2019 2:20:35 PM Hong Kong Standard Time
en-rID FULL Monday, May 6, 2019 4:08:09 AM Hong Kong Standard Time Friday, October 25, 2019 2:20:35 PM Hong Kong Standard Time
en-rIN FULL Monday 6 May 2019 4:08:09 AM Hong Kong Standard Time Friday 25 October 2019 2:20:35 PM Hong Kong Standard Time
en-rMY FULL Monday, 6 May 2019 4:08:09 AM Hong Kong Standard Time Friday, 25 October 2019 2:20:35 PM Hong Kong Standard Time
en-rPH FULL Monday, 6 May 2019 4:08:09 AM Hong Kong Standard Time Friday, 25 October 2019 2:20:35 PM Hong Kong Standard Time
en-rSG FULL Monday, 6 May 2019 4:08:09 AM Hong Kong Standard Time Friday, 25 October 2019 2:20:35 PM Hong Kong Standard Time
en-rTH FULL Monday, May 6, 2019 4:08:09 AM Hong Kong Standard Time Friday, October 25, 2019 2:20:35 PM Hong Kong Standard Time
en-rUS FULL Monday, May 6, 2019 4:08:09 AM Hong Kong Standard Time Friday, October 25, 2019 2:20:35 PM Hong Kong Standard Time
en-rVN FULL Monday, May 6, 2019 4:08:09 AM Hong Kong Standard Time Friday, October 25, 2019 2:20:35 PM Hong Kong Standard Time
hi-rIN FULL सोमवार, 6 मई 2019 4:08:09 am हाँग काँग मानक समय शुक्रवार, 25 अक्तूबर 2019 2:20:35 pm हाँग काँग मानक समय
in-rID FULL Senin, 06 Mei 2019 04.08.09 Waktu Standar Hong Kong Jumat, 25 Oktober 2019 14.20.35 Waktu Standar Hong Kong
ms-rMY FULL Isnin, 6 Mei 2019 4:08:09 PG Waktu Piawai Hong Kong Jumaat, 25 Oktober 2019 2:20:35 PTG Waktu Piawai Hong Kong
th-rTH FULL วันจันทร์ที่ 6 พฤษภาคม ค.ศ. 2019 4 นาฬิกา 08 นาที 09 วินาที เวลามาตรฐานฮ่องกง วันศุกร์ที่ 25 ตุลาคม ค.ศ. 2019 14 นาฬิกา 20 นาที 35 วินาที เวลามาตรฐานฮ่องกง
vi-rVN FULL Thứ Hai, 6 tháng 5, 2019 04:08:09 Giờ Chuẩn Hồng Kông Thứ Sáu, 25 tháng 10, 2019 14:20:35 Giờ Chuẩn Hồng Kông
zh-rHK FULL 2019年5月6日星期一 上午4:08:09 [香港標準時間] 2019年10月25日星期五 下午2:20:35 [香港標準時間]
zh-rTW FULL 2019年5月6日 星期一 上午4:08:09 [香港標準時間] 2019年10月25日 星期五 下午2:20:35 [香港標準時間]

24-hour Format

System Default - SHORT

Locale Style Formatted Timestamp A (Date) Formatted Timestamp A (Time) Formatted Timestamp B (Date) Formatted Timestamp B (Time)
en-rHK SHORT 6/5/2019 04:08 25/10/2019 14:20
en-rID SHORT 5/6/19 04:08 10/25/19 14:20
en-rIN SHORT 06/05/19 04:08 25/10/19 14:20
en-rMY SHORT 06/05/2019 04:08 25/10/2019 14:20
en-rPH SHORT 06/05/2019 04:08 25/10/2019 14:20
en-rSG SHORT 6/5/19 04:08 25/10/19 14:20
en-rTH SHORT 5/6/19 04:08 10/25/19 14:20
en-rUS SHORT 5/6/19 04:08 10/25/19 14:20
en-rVN SHORT 5/6/19 04:08 10/25/19 14:20
hi-rIN SHORT 6/5/19 04:08 25/10/19 14:20
in-rID SHORT 06/05/19 04.08 25/10/19 14.20
ms-rMY SHORT 6/05/19 04:08 25/10/19 14:20
th-rTH SHORT 6/5/19 04:08 น. 25/10/19 14:20 น.
vi-rVN SHORT 06/05/2019 4:08 25/10/2019 14:20
zh-rHK SHORT 6/5/2019 04:08 25/10/2019 14:20
zh-rTW SHORT 2019/5/6 04:08 2019/10/25 14:20

System Default - MEDIUM

Locale Style Formatted Timestamp A (Date) Formatted Timestamp A (Time) Formatted Timestamp B (Date) Formatted Timestamp B (Time)
en-rHK MEDIUM 6 May 2019 04:08:09 25 Oct 2019 14:20:35
en-rID MEDIUM May 6, 2019 04:08:09 Oct 25, 2019 14:20:35
en-rIN MEDIUM 06-May-2019 04:08:09 25-Oct-2019 14:20:35
en-rMY MEDIUM 6 May 2019 04:08:09 25 Oct 2019 14:20:35
en-rPH MEDIUM 6 May 2019 04:08:09 25 Oct 2019 14:20:35
en-rSG MEDIUM 6 May 2019 04:08:09 25 Oct 2019 14:20:35
en-rTH MEDIUM May 6, 2019 04:08:09 Oct 25, 2019 14:20:35
en-rUS MEDIUM May 6, 2019 04:08:09 Oct 25, 2019 14:20:35
en-rVN MEDIUM May 6, 2019 04:08:09 Oct 25, 2019 14:20:35
hi-rIN MEDIUM 06/05/2019 04:08:09 25/10/2019 14:20:35
in-rID MEDIUM 6 Mei 2019 04.08.09 25 Okt 2019 14.20.35
ms-rMY MEDIUM 6 Mei 2019 04:08:09 25 Okt 2019 14:20:35
th-rTH MEDIUM 6 พ.ค. 2019 04:08:09 25 ต.ค. 2019 14:20:35
vi-rVN MEDIUM 6 thg 5, 2019 04:08:09 25 thg 10, 2019 14:20:35
zh-rHK MEDIUM 2019年5月6日 04:08:09 2019年10月25日 14:20:35
zh-rTW MEDIUM 2019年5月6日 04:08:09 2019年10月25日 14:20:35

System Default - LONG

Locale Style Formatted Timestamp A (Date) Formatted Timestamp A (Time) Formatted Timestamp B (Date) Formatted Timestamp B (Time)
en-rHK LONG 6 May 2019 4:08:09 AM HKT 25 October 2019 2:20:35 PM HKT
en-rID LONG May 6, 2019 4:08:09 AM GMT+08:00 October 25, 2019 2:20:35 PM GMT+08:00
en-rIN LONG 6 May 2019 4:08:09 AM GMT+08:00 25 October 2019 2:20:35 PM GMT+08:00
en-rMY LONG 6 May 2019 4:08:09 AM GMT+08:00 25 October 2019 2:20:35 PM GMT+08:00
en-rPH LONG 6 May 2019 4:08:09 AM GMT+08:00 25 October 2019 2:20:35 PM GMT+08:00
en-rSG LONG 6 May 2019 4:08:09 AM GMT+08:00 25 October 2019 2:20:35 PM GMT+08:00
en-rTH LONG May 6, 2019 4:08:09 AM GMT+08:00 October 25, 2019 2:20:35 PM GMT+08:00
en-rUS LONG May 6, 2019 4:08:09 AM GMT+08:00 October 25, 2019 2:20:35 PM GMT+08:00
en-rVN LONG May 6, 2019 4:08:09 AM GMT+08:00 October 25, 2019 2:20:35 PM GMT+08:00
hi-rIN LONG 6 मई 2019 4:08:09 am GMT+08:00 25 अक्तूबर 2019 2:20:35 pm GMT+08:00
in-rID LONG 6 Mei 2019 04.08.09 GMT+08:00 25 Oktober 2019 14.20.35 GMT+08:00
ms-rMY LONG 6 Mei 2019 4:08:09 PG GMT+08:00 25 Oktober 2019 2:20:35 PTG GMT+08:00
th-rTH LONG 6 พฤษภาคม ค.ศ. 2019 4 นาฬิกา 08 นาที 09 วินาที GMT+08:00 25 ตุลาคม ค.ศ. 2019 14 นาฬิกา 20 นาที 35 วินาที GMT+08:00
vi-rVN LONG 6 tháng 5, 2019 04:08:09 GMT+08:00 25 tháng 10, 2019 14:20:35 GMT+08:00
zh-rHK LONG 2019年5月6日 上午4:08:09 [GMT+08:00] 2019年10月25日 下午2:20:35 [GMT+08:00]
zh-rTW LONG 2019年5月6日 上午4:08:09 [GMT+08:00] 2019年10月25日 下午2:20:35 [GMT+08:00]

System Default - FULL

Locale Style Formatted Timestamp A (Date) Formatted Timestamp A (Time) Formatted Timestamp B (Date) Formatted Timestamp B (Time)
en-rHK FULL Monday, 6 May 2019 4:08:09 AM Hong Kong Standard Time Friday, 25 October 2019 2:20:35 PM Hong Kong Standard Time
en-rID FULL Monday, May 6, 2019 4:08:09 AM Hong Kong Standard Time Friday, October 25, 2019 2:20:35 PM Hong Kong Standard Time
en-rIN FULL Monday 6 May 2019 4:08:09 AM Hong Kong Standard Time Friday 25 October 2019 2:20:35 PM Hong Kong Standard Time
en-rMY FULL Monday, 6 May 2019 4:08:09 AM Hong Kong Standard Time Friday, 25 October 2019 2:20:35 PM Hong Kong Standard Time
en-rPH FULL Monday, 6 May 2019 4:08:09 AM Hong Kong Standard Time Friday, 25 October 2019 2:20:35 PM Hong Kong Standard Time
en-rSG FULL Monday, 6 May 2019 4:08:09 AM Hong Kong Standard Time Friday, 25 October 2019 2:20:35 PM Hong Kong Standard Time
en-rTH FULL Monday, May 6, 2019 4:08:09 AM Hong Kong Standard Time Friday, October 25, 2019 2:20:35 PM Hong Kong Standard Time
en-rUS FULL Monday, May 6, 2019 4:08:09 AM Hong Kong Standard Time Friday, October 25, 2019 2:20:35 PM Hong Kong Standard Time
en-rVN FULL Monday, May 6, 2019 4:08:09 AM Hong Kong Standard Time Friday, October 25, 2019 2:20:35 PM Hong Kong Standard Time
hi-rIN FULL सोमवार, 6 मई 2019 4:08:09 am हाँग काँग मानक समय शुक्रवार, 25 अक्तूबर 2019 2:20:35 pm हाँग काँग मानक समय
in-rID FULL Senin, 06 Mei 2019 04.08.09 Waktu Standar Hong Kong Jumat, 25 Oktober 2019 14.20.35 Waktu Standar Hong Kong
ms-rMY FULL Isnin, 6 Mei 2019 4:08:09 PG Waktu Piawai Hong Kong Jumaat, 25 Oktober 2019 2:20:35 PTG Waktu Piawai Hong Kong
th-rTH FULL วันจันทร์ที่ 6 พฤษภาคม ค.ศ. 2019 4 นาฬิกา 08 นาที 09 วินาที เวลามาตรฐานฮ่องกง วันศุกร์ที่ 25 ตุลาคม ค.ศ. 2019 14 นาฬิกา 20 นาที 35 วินาที เวลามาตรฐานฮ่องกง
vi-rVN FULL Thứ Hai, 6 tháng 5, 2019 04:08:09 Giờ Chuẩn Hồng Kông Thứ Sáu, 25 tháng 10, 2019 14:20:35 Giờ Chuẩn Hồng Kông
zh-rHK FULL 2019年5月6日星期一 上午4:08:09 [香港標準時間] 2019年10月25日星期五 下午2:20:35 [香港標準時間]
zh-rTW FULL 2019年5月6日 星期一 上午4:08:09 [香港標準時間] 2019年10月25日 星期五 下午2:20:35 [香港標準時間]

Code

@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private fun dateFormat() {
    val date1 = Date(1557086889000L) // Monday, 6 May 2019 04:08:09 GMT+08:00
    val date2 = Date(1571984435000L) // Friday, 25 October 2019 14:20:35 GMT+08:00

    val formatters = mapOf(
            "SHORT" to DateFormat.SHORT,
            "MEDIUM" to DateFormat.MEDIUM,
            "LONG" to DateFormat.LONG,
            "FULL" to DateFormat.FULL
    )

    val locales = arrayOf("en-rHK", "en-rID", "en-rIN", "en-rMY", "en-rPH", "en-rSG", "en-rTH", "en-rUS", "en-rVN", "hi-rIN", "in-rID", "ms-rMY", "th-rTH", "vi-rVN", "zh-rHK", "zh-rTW")

    formatters.forEach { (key, formatter) ->
        Timber.d("dateFormat: ")
        Timber.d("dateFormat: ## System Default - $key")
        Timber.d("dateFormat: ")
        Timber.d("dateFormat: |Locale|Style|Formatted Timestamp A (Date)|Formatted Timestamp A (Time)|Formatted Timestamp B (Date)|Formatted Timestamp B (Time)|")
        Timber.d("dateFormat: |---|---|---|---|---|---|")
        locales.forEach { lo ->
            val result = lo.split("-r")
            val locale = Locale(result[0], result[1])
            val dateFormat = DateFormat.getDateInstance(formatter, locale)
            val timeFormat = DateFormat.getTimeInstance(formatter, locale)
            Timber.d("dateFormat: |$lo|$key|${dateFormat.format(date1)}|${timeFormat.format(date1)}|${dateFormat.format(date2)}|${timeFormat.format(date2)}|")
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment