Tuesday 20 April 2021

Maximo Date Format Conversion Using Automation Scripts

We can convert the normal date format to Maximo date format (yyyy-mm-ddThh:mm:ss.ffffff) using Automation Script.

Script Language: javascript

load("nashorn:mozilla_compat.js");
importPackage(Packages.java.text);

erData.breakData();
var actualDate = erData.getCurrentData("ACTUALDATE");
print("INPUT : " +actualDate);

var inputFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
var outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
var dateParse = inputFormat.parse(actualDate);
var maximoDate = (outputFormat.format(dateParse)).replace(" ", "T") +"+05:30";
print("OUTPUT : " +maximoDate);

erData.setCurrentData("ACTUALDATE", maximoDate);

Output:

INPUT : 4/20/2021 03:30:52 PM
OUTPUT : 2021-04-20T15:30:52+08:00

Monday 8 March 2021

Maximo Date Manipulation Using Automation Scripts

In this topic, we are going to see how to manipulate Maximo dates using Automation scripts. The different kinds of manipulation are

  1. Adding Number to the date
  2. Subtracting Number to the date
  3. Changing the format of the date
  4. Difference between two dates in days 

In the below examples we are going to use Python scripts in Maximo

  1. Object Launch Point is used
  2. Asset object
  3. The “INSTALLDATE” attribute is modified

  Java Calendar class is used for Date Manipulation.


1.     Adding Number to the date

Current date from MXServer is got and adding number (10) to that date.

print("**************Start of C_TEST ********************")
from java.util import Date
from java.util import Calendar
from psdi.server import MXServer

currentDate = MXServer.getMXServer().getDate()
cal = Calendar.getInstance()
cal.setTime(currentDate)

cal.add(Calendar.DATE, 10) 

print ("After Additional to Current Date ---> ",cal.getTime()) 

mbo.setValue("INSTALLDATE",cal.getTime()) 
print("**************End of C_TEST ********************")