Skip to content

Commit 8173d68

Browse files
authored
Merge pull request #2609 from hongwei1/bug/fixedBgV13Dateformat
Hongwei/bug/fixedBgV13Dateformat
2 parents 92870ea + f796169 commit 8173d68

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
.settings
99
.metals
1010
.vscode
11+
*.code-workspace
1112
.zed
13+
.cursor
1214
.classpath
1315
.project
1416
.cache
@@ -35,5 +37,4 @@ marketing_diagram_generation/outputs/*
3537
.bsp
3638
.specstory
3739
project/project
38-
coursier
39-
*.code-workspace
40+
coursier

obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
346346
Some(balances.filter(_.accountId.equals(x.accountId)).flatMap(balance => (List(CoreAccountBalanceJson(
347347
balanceAmount = AmountOfMoneyV13(x.currency, balance.balanceAmount.toString()),
348348
balanceType = balance.balanceType,
349-
lastChangeDateTime = balance.lastChangeDateTime.map(APIUtil.DateWithMsAndTimeZoneOffset.format(_))
349+
lastChangeDateTime = balance.lastChangeDateTime.map(APIUtil.DateWithMsFormat.format(_))
350350
)))))
351351
}else{
352352
None
@@ -432,7 +432,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
432432
Some(balances.filter(_.accountId.equals(bankAccount.accountId)).flatMap(balance => (List(CoreAccountBalanceJson(
433433
balanceAmount = AmountOfMoneyV13(bankAccount.currency, balance.balanceAmount.toString()),
434434
balanceType = balance.balanceType,
435-
lastChangeDateTime = balance.lastChangeDateTime.map(APIUtil.DateWithMsAndTimeZoneOffset.format(_))
435+
lastChangeDateTime = balance.lastChangeDateTime.map(APIUtil.DateWithMsFormat.format(_))
436436
)))))
437437
} else {
438438
None
@@ -477,7 +477,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
477477
`balances` = accountBalances.map(accountBalance => AccountBalance(
478478
balanceAmount = AmountOfMoneyV13(bankAccount.currency, accountBalance.balanceAmount.toString()),
479479
balanceType = accountBalance.balanceType,
480-
lastChangeDateTime = accountBalance.lastChangeDateTime.map(APIUtil.DateWithMsAndTimeZoneOffset.format(_)),
480+
lastChangeDateTime = accountBalance.lastChangeDateTime.map(APIUtil.DateWithMsFormat.format(_)),
481481
referenceDate = accountBalance.referenceDate,
482482
)
483483
))
@@ -614,8 +614,8 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
614614
else
615615
transaction.amount.get.toString()
616616
),
617-
bookingDate = transaction.startDate.map(APIUtil.DateWithMsAndTimeZoneOffset.format(_)).getOrElse(""),
618-
valueDate = transaction.finishDate.map(APIUtil.DateWithMsAndTimeZoneOffset.format(_)).getOrElse(""),
617+
bookingDate = transaction.startDate.map(APIUtil.DateWithMsFormat.format(_)).getOrElse(""),
618+
valueDate = transaction.finishDate.map(APIUtil.DateWithMsFormat.format(_)).getOrElse(""),
619619
remittanceInformationUnstructured = transaction.description.getOrElse(""),
620620
bankTransactionCode ="",
621621
)

obp-api/src/main/scala/code/api/util/APIUtil.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,11 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{
130130
val DateWithMonthFormat = new SimpleDateFormat(DateWithMonth)
131131
val DateWithDayFormat = new SimpleDateFormat(DateWithDay)
132132
val DateWithSecondsFormat = new SimpleDateFormat(DateWithSeconds)
133-
val DateWithMsFormat = new SimpleDateFormat(DateWithMs)
133+
// If you need UTC Z format, please continue to use DateWithMsFormat. eg: 2025-01-01T01:01:01.000Z
134+
val DateWithMsFormat = new SimpleDateFormat(DateWithMs)
135+
// If you need a format with timezone offset (+0000), please use DateWithMsRollbackFormat, eg: 2025-01-01T01:01:01.000+0000
134136
val DateWithMsRollbackFormat = new SimpleDateFormat(DateWithMsAndTimeZoneOffset)
137+
135138
val rfc7231Date = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH)
136139

137140
val DateWithYearExampleString: String = "1100"
@@ -967,7 +970,7 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{
967970
if(date == null)
968971
None
969972
else
970-
Some(APIUtil.DateWithMsAndTimeZoneOffset.format(date))
973+
Some(APIUtil.DateWithMsRollbackFormat.format(date))
971974

972975
def stringOrNull(text : String) =
973976
if(text == null || text.isEmpty)

obp-api/src/test/scala/code/util/APIUtilTest.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ class APIUtilTest extends FeatureSpec with Matchers with GivenWhenThen with Prop
5555
val inputStringDateFormat = DateWithMsFormat
5656
val startDateObject: Date = DateWithMsFormat.parse(DefaultFromDateString)
5757
val endDateObject: Date = DateWithMsFormat.parse(DefaultToDateString)
58+
59+
feature("Test the value of dateString formatted by DateWithMsFormat") {
60+
scenario("Check the formatted dateString value") {
61+
val dateString = inputStringDateFormat.format(new Date())
62+
// println(s"dateString value: $dateString")
63+
dateString should not be "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
64+
}
65+
}
66+
5867
ZonedDateTime.now(ZoneId.of("UTC"))
5968

6069
feature("test APIUtil.dateRangesOverlap method") {

0 commit comments

Comments
 (0)