From f744eecbfc31e49e3fc173beb1a62bee2a2a5f9f Mon Sep 17 00:00:00 2001 From: hongwei Date: Tue, 9 Sep 2025 16:42:40 +0200 Subject: [PATCH 1/3] refactor/ Update .gitignore to include .cursor and retain .code-workspace entry --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8d45672308..2e7ba93bf6 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,5 @@ marketing_diagram_generation/outputs/* .specstory project/project coursier -*.code-workspace \ No newline at end of file +*.code-workspace +.cursor \ No newline at end of file From 129b52c35b1fe0ec06c91fe77d97ddbb2e8b577d Mon Sep 17 00:00:00 2001 From: hongwei Date: Tue, 16 Sep 2025 14:20:11 +0200 Subject: [PATCH 2/3] refactor/Update date formatting in JSONFactory and APIUtil to use DateWithMsFormat instead of DateWithMsAndTimeZoneOffset --- .../group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala | 10 +++++----- obp-api/src/main/scala/code/api/util/APIUtil.scala | 2 +- obp-api/src/test/scala/code/util/APIUtilTest.scala | 9 +++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala b/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala index 52d78bfb38..db3c00a741 100644 --- a/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala +++ b/obp-api/src/main/scala/code/api/berlin/group/v1_3/JSONFactory_BERLIN_GROUP_1_3.scala @@ -346,7 +346,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{ Some(balances.filter(_.accountId.equals(x.accountId)).flatMap(balance => (List(CoreAccountBalanceJson( balanceAmount = AmountOfMoneyV13(x.currency, balance.balanceAmount.toString()), balanceType = balance.balanceType, - lastChangeDateTime = balance.lastChangeDateTime.map(APIUtil.DateWithMsAndTimeZoneOffset.format(_)) + lastChangeDateTime = balance.lastChangeDateTime.map(APIUtil.DateWithMsFormat.format(_)) ))))) }else{ None @@ -432,7 +432,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{ Some(balances.filter(_.accountId.equals(bankAccount.accountId)).flatMap(balance => (List(CoreAccountBalanceJson( balanceAmount = AmountOfMoneyV13(bankAccount.currency, balance.balanceAmount.toString()), balanceType = balance.balanceType, - lastChangeDateTime = balance.lastChangeDateTime.map(APIUtil.DateWithMsAndTimeZoneOffset.format(_)) + lastChangeDateTime = balance.lastChangeDateTime.map(APIUtil.DateWithMsFormat.format(_)) ))))) } else { None @@ -477,7 +477,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{ `balances` = accountBalances.map(accountBalance => AccountBalance( balanceAmount = AmountOfMoneyV13(bankAccount.currency, accountBalance.balanceAmount.toString()), balanceType = accountBalance.balanceType, - lastChangeDateTime = accountBalance.lastChangeDateTime.map(APIUtil.DateWithMsAndTimeZoneOffset.format(_)), + lastChangeDateTime = accountBalance.lastChangeDateTime.map(APIUtil.DateWithMsFormat.format(_)), referenceDate = accountBalance.referenceDate, ) )) @@ -614,8 +614,8 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{ else transaction.amount.get.toString() ), - bookingDate = transaction.startDate.map(APIUtil.DateWithMsAndTimeZoneOffset.format(_)).getOrElse(""), - valueDate = transaction.finishDate.map(APIUtil.DateWithMsAndTimeZoneOffset.format(_)).getOrElse(""), + bookingDate = transaction.startDate.map(APIUtil.DateWithMsFormat.format(_)).getOrElse(""), + valueDate = transaction.finishDate.map(APIUtil.DateWithMsFormat.format(_)).getOrElse(""), remittanceInformationUnstructured = transaction.description.getOrElse(""), bankTransactionCode ="", ) diff --git a/obp-api/src/main/scala/code/api/util/APIUtil.scala b/obp-api/src/main/scala/code/api/util/APIUtil.scala index 700d5e742e..e7cc1f3ae5 100644 --- a/obp-api/src/main/scala/code/api/util/APIUtil.scala +++ b/obp-api/src/main/scala/code/api/util/APIUtil.scala @@ -955,7 +955,7 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{ if(date == null) None else - Some(APIUtil.DateWithMsAndTimeZoneOffset.format(date)) + Some(APIUtil.DateWithMsRollbackFormat.format(date)) def stringOrNull(text : String) = if(text == null || text.isEmpty) diff --git a/obp-api/src/test/scala/code/util/APIUtilTest.scala b/obp-api/src/test/scala/code/util/APIUtilTest.scala index e3f546935e..78c08a92c6 100644 --- a/obp-api/src/test/scala/code/util/APIUtilTest.scala +++ b/obp-api/src/test/scala/code/util/APIUtilTest.scala @@ -55,6 +55,15 @@ class APIUtilTest extends FeatureSpec with Matchers with GivenWhenThen with Prop val inputStringDateFormat = DateWithMsFormat val startDateObject: Date = DateWithMsFormat.parse(DefaultFromDateString) val endDateObject: Date = DateWithMsFormat.parse(DefaultToDateString) + + feature("Test the value of dateString formatted by DateWithMsAndTimeZoneOffset") { + scenario("Check the formatted dateString value") { + val dateString = APIUtil.DateWithMsFormat.format(new Date()) +// println(s"dateString value: $dateString") + dateString should not be "yyyy-MM-dd'T'HH:mm:ss.SSSZ" + } + } + ZonedDateTime.now(ZoneId.of("UTC")) feature("test APIUtil.dateRangesOverlap method") { From 838a00d841664d9cd75d3db0cf20d2282d5121a1 Mon Sep 17 00:00:00 2001 From: hongwei Date: Tue, 16 Sep 2025 14:39:53 +0200 Subject: [PATCH 3/3] refactor/Clarify date formatting usage in APIUtil and update related tests to reflect changes --- obp-api/src/main/scala/code/api/util/APIUtil.scala | 5 ++++- obp-api/src/test/scala/code/util/APIUtilTest.scala | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/obp-api/src/main/scala/code/api/util/APIUtil.scala b/obp-api/src/main/scala/code/api/util/APIUtil.scala index e7cc1f3ae5..5a50c1a0f6 100644 --- a/obp-api/src/main/scala/code/api/util/APIUtil.scala +++ b/obp-api/src/main/scala/code/api/util/APIUtil.scala @@ -130,8 +130,11 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{ val DateWithMonthFormat = new SimpleDateFormat(DateWithMonth) val DateWithDayFormat = new SimpleDateFormat(DateWithDay) val DateWithSecondsFormat = new SimpleDateFormat(DateWithSeconds) - val DateWithMsFormat = new SimpleDateFormat(DateWithMs) + // If you need UTC Z format, please continue to use DateWithMsFormat. eg: 2025-01-01T01:01:01.000Z + val DateWithMsFormat = new SimpleDateFormat(DateWithMs) + // If you need a format with timezone offset (+0000), please use DateWithMsRollbackFormat, eg: 2025-01-01T01:01:01.000+0000 val DateWithMsRollbackFormat = new SimpleDateFormat(DateWithMsAndTimeZoneOffset) + val rfc7231Date = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH) val DateWithYearExampleString: String = "1100" diff --git a/obp-api/src/test/scala/code/util/APIUtilTest.scala b/obp-api/src/test/scala/code/util/APIUtilTest.scala index 78c08a92c6..000221b280 100644 --- a/obp-api/src/test/scala/code/util/APIUtilTest.scala +++ b/obp-api/src/test/scala/code/util/APIUtilTest.scala @@ -56,9 +56,9 @@ class APIUtilTest extends FeatureSpec with Matchers with GivenWhenThen with Prop val startDateObject: Date = DateWithMsFormat.parse(DefaultFromDateString) val endDateObject: Date = DateWithMsFormat.parse(DefaultToDateString) - feature("Test the value of dateString formatted by DateWithMsAndTimeZoneOffset") { + feature("Test the value of dateString formatted by DateWithMsFormat") { scenario("Check the formatted dateString value") { - val dateString = APIUtil.DateWithMsFormat.format(new Date()) + val dateString = inputStringDateFormat.format(new Date()) // println(s"dateString value: $dateString") dateString should not be "yyyy-MM-dd'T'HH:mm:ss.SSSZ" }