Tuesday 23 October 2018

Add one day to the input date in SAP HCI/CPI

Increment the date with day by 1.

Received a requirement to add one day to the input date. Script is implemented in the mapping level to achieve this functionality.

Groovy Script:


import com.sap.it.api.mapping.*;

def String IncrementDateByOne1(String dateInput){

def dateFormat = 'yyyy-MM-dd'
try{
//For any date
def dateString = dateInput
def date = Date.parse(dateFormat, dateString)
//log.info date.nextDay()

            return date.nextDay()
}
catch(Exception ex){
    return ""
}
}

Input: 2012-01-03 19:10:10
Output: 2012-01-04



No comments:

Post a Comment