3

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!

3 Answers3

5

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.

Christian Strempfer
  • 7,291
  • 6
  • 50
  • 75
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.

Lucifer
  • 29,392
  • 25
  • 90
  • 143
ngrashia
  • 9,869
  • 5
  • 43
  • 58
0

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)

Happyblue
  • 129
  • 1
  • 4
  • if you use `searchString=^(.{10})` and `replaceString=$1` you are just asking to find a group (anchored at the beginning of the string) and replacing it with itself. The correct `searchString=^(.{10}).*` means you are searching for the full string, with a group pattern, AND replacing the entire string for the group. – gvlx Oct 12 '16 at 08:59