What transformer can I use to put a date into YYYY - MM - DD format with no time format in final result?

StackOverflow https://stackoverflow.com/questions/22461128

  •  16-06-2023
  •  | 
  •  

Question

I just started using webMETHODS today and need to transform a date input value that comes in like this.

Example:

yyyy-mm-dd hh:mm:ss:hh

I need just the date portion of this variable and am currently using pub.date:formatDate which will crash my flow service.

What should I be using?

This is what I see on my WEBMethods screen!

Was it helpful?

Solution 2

pub.date:formatDate is used to convert a date input to a string output based on a string pattern. Here you are trying to convert a string input to a string output.

You have to do the following: a. First convert the string (Process_date_orig_str) to date format (Process_date_dt) b. Then use the date (Process_date_dt) to the required string format using pub.date:formatDate to get (Process_date_new_str)

Note: You will have to create your custom java service to convert string to Date.

OTHER TIPS

An alternative would be to use pub.date:dateTimeFormat, which allows you to set an input pattern, for example dd.MM.yyyy hh:mm:ss.

I played around with this for practise. The 'correct' answer is what Christian Strempfer posted - this is what pub.date:dateTimeFormat is meant to do: transform beween datetime string formats. I'm not sure about your date pattern though - try currentPattern=yyyy-MM-dd HH:mm:ss.SS and newPattern=yyyy-MM-dd

A 'good hacky approach is using pub.string:subString (positions 0 and 10) to simply hack the end off the input string. You can also try regexs -- pub.string:replace, useRegex=true, searchString=^(.{10}).*, replaceString=$1. (searchString=^(.{10}) should also work, but it doesn't)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top