web stats
Mirth Community - View Single Post - Mirth Tools: User defined functions
View Single Post
  #51  
Old 02-21-2018, 08:37 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,109
agermano is on a distinguished road
Default Format offset of current local time as string

I made a library because I needed to get a formatted datetime string for x number of days prior to now to use in a File Reader.

I put the following line in my channel deploy script to place the object in my globalChannelMap, but I suppose that it could also go in the global deploy script and globalMap, since each channel really doesn't need its own instance of it.
Code:
// Get object from code template that can be used to generate filenames with dates in the past.
$gc('mdu', MyDateUtil.getJavaObject());
Then for my Filename Filter Pattern I would use the following to get four days ago:
Code:
prefix_${mdu.formatCurrentDateTimeByOffset('yyyyMMdd', 'days', -4)}
It uses java 8 time functions and can do offsets in units from nanos to years.
Attached Files
File Type: xml MyDateUtil.xml (6.8 KB, 26 views)
Reply With Quote