Last active
March 2, 2020 04:46
-
-
Save haohcraft/ec4ea68404144cefedb04c64e4e946cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@DisplayName("Given a value with two data format, When use setDateFormat on GsonBuilder and a simpleDateFormat, Then return as expected") | |
@Test | |
fun testSetDateFormatWithSimpleDateFormat() { | |
val gson = GsonBuilder().apply { | |
setDateFormat("yyyy-MM-dd HH:mm:ss") | |
}.create() | |
val dateFormatter = SimpleDateFormat(targetFormat, Locale.US) | |
val result = gson.fromJson(testJsonString, SerializationTestData::class.java) | |
assertEquals("2020-03-23", dateFormatter.format(result.startDate)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment