Question
Coforge
IN
Last activity: 30 Jul 2024 5:54 EDT
How to format date from input=20240726 to output=26-07-2024
I have a requirement to convert Date in format 20240726 to 26-07-2024 . how can we achive this?
Note:
1) input is date type: 20240726 and output 26-07-2024 is also should be in date type after converting.
eg: input property name : TestDate consists value 20240726
i tried to convert using pxFormatDateOnly [@pxFormatDateOnly(.TestDate,"yyyyMMdd","dd/MM/yyyy")]
so by using this the date converted into 26/07/2024 but when i try to save the value to TestDate property again it says that 26/07/2024 is not valid date property since it was string. so after conversion also it should be in date format only.
-
Reply
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Maantic Inc
IN
A dateonly property cannot have special chars. So you need to convert the property type to text. Else you can display the formatted value on the UI, but backed save as yyyyMMdd
Coforge
IN
agree, we can format on UI .But just wanted to know is this possible with java on Edit input (property)?
Thanks
Maantic Inc
IN
Do you want to validate if the date entered by he user is valid or not?
Coforge
IN
Pegasystems Inc.
IN
You can refer this post its clearly mentioned here
Coforge
IN
@pxFormatDateOnly(Param.Date,Param.CurrentFormat,Param.ToFormat) this will convert into string data type is there a way it converts into date data type?
Pegasystems Inc.
IN
What exactly is your requirement, here you can use the existing Date control and give the format as you required to display on screen . PFA
as @SohamM95 mentioned in the backend it will not be stored with special chars it will be always yyyymmdd for date and GMT format for Date time
Coforge
IN
i am not using in UI . i was trying to append the datestring to date property. can u see the attached ss below.
Thanks
Pegasystems Inc.
IN
@pavankillada i think when the date string is assigned to a date property, it should be changed to date. Pls try that out
Coforge
IN
Pegasystems Inc.
IN
@pavankillada I misunderstood. in this case, as nagarjuna suggested, try using the UI control