How to convert a string to date without knowing the format

Hi All,

We have a service which returns a date in the response. Here the date can be in various formats and it is not consistent.

For example, it returns date as “05-MAR-2021” or “2021-03-05” or etc… .

Now we need to convert this date in string format to Date format YYYYMMDD.

Any leads on this please?

@SANTOSHKY Hi,

Please try to use DateValidatorUsingDateTimeFormatter and check the format varient accordingly right an function based on this and use it.

hope you might got some idea.

@SANTOSHKY You can create a RUF and write the following custom java code to covert the String date in the required data format:

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

String dateString = format.format( new Date()   );
Date   date       = format.parse ( "2009-12-31" );    

Hope this solves your problem.

Thanks