Jump to content

Hello Experts, How to get the number of days from a given month in Tibco BW 6.x? Thanks in advance.

Recommended Posts

  • 5 weeks later...

Hello @Chinnakanna C​ 

Natively, I'm not aware of any built-in function that can return the information you need. Alternatively, you can obtain this information using Java in a "Java Invoke" activity or in a "Custom Function."

Here's an example using the "Java Invoke" activity:

1 - Create a process and insert a "Timer" activity, then transition to a "Java Invoke" activity.

step01.png.46ab208ce861ebfdae6ce64b6df8019e.png2- Select the "Java Invoke" activity and in the "General" tab, click on "New Class."


3 - In the "name" field of the new class editor, enter "GetNumberOfDaysFromGivenMonth", or another name of your choice, and click "Finish."

step03.png.343221c3ad1984a369b4e545a61b004c.png4- The class editor will appear, but we won't make changes to it for now, so simply save the project.

5- Return to the created process and go to the "Java Invoke" activity. Select the "General" tab, choose the "multiOutput" option, and set the input and output parameters as shown in the image below. Save the project.

step05.thumb.png.a220988116adc99ef40c4aef97b72dd3.png6- Return to the editor of the class "GetNumberOfDaysFromGivenMonth" and review the input and output parameters that have already been defined. The method getNumberOfDays() was also created.

7- In the class editor, import the library "import java.time.YearMonth;". Inside the method, insert the logic to obtain the number of days in the month. You can remove the "import java.util.*;" as it will not be used. The code should look like the image below.

step07.png.4f97f784ecb024af1e1c491a338406ea.png8 - Save the changes you've made and return to the process. In the "General" tab of the activity, select and in the "Method" option, choose the "invoke()" method.

9- Navigate to the "Input" tab and provide the desired month and year. In my test, I entered 02/2023. Execute the process and observe the result, as shown in the example image below.

step09.thumb.png.4218a60f8b9dea04b03a0b966e43df09.pngBest Regards.

Link to comment
Share on other sites

  • Create New...