1package com.parseable.android
3import com.parseable.android.data.formatTimestamp
4import org.junit.Assert.*
6import java.util.TimeZone
8class FormatTimestampTest {
11 fun `formats ISO8601 UTC timestamp`() {
12 // Force UTC for test determinism
13 val original = TimeZone.getDefault()
15 TimeZone.setDefault(TimeZone.getTimeZone("UTC"))
16 val result = formatTimestamp("2024-12-15T14:30:45.123Z")
17 assertEquals("Dec 15 14:30:45.123", result)
19 TimeZone.setDefault(original)
24 fun `formats Parseable timestamp format with +00 00 suffix`() {
25 val original = TimeZone.getDefault()
27 TimeZone.setDefault(TimeZone.getTimeZone("UTC"))
28 val result = formatTimestamp("2024-12-15T14:30:45.123456+00:00")
29 assertEquals("Dec 15 14:30:45.123", result)
31 TimeZone.setDefault(original)
36 fun `returns raw string for unparseable timestamp`() {
37 val result = formatTimestamp("not-a-timestamp")
38 assertEquals("not-a-timestamp", result)
42 fun `handles empty string`() {
43 val result = formatTimestamp("")
44 assertEquals("", result)
48 fun `converts to local timezone`() {
49 val original = TimeZone.getDefault()
51 TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"))
52 val result = formatTimestamp("2024-06-15T18:30:45.000Z")
54 assertEquals("Jun 15 14:30:45.000", result)
56 TimeZone.setDefault(original)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list