Reputation: 11
I am working with WODM rule designer V7.5, my XOM is an XSD
I should compare the date of a transaction with the current date, so if a client does a transaction, the expiration date of his account should be incremented by one year !
Dates in my XOM are Strings, so in the BOM TO XOM MAPPING part of my BOM I created 2 methods :
one that returns the actual date as a string, verbalized as : today on the calendar
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String s = dateFormat.format(date);
return s;
one that takes a string, convert it to Date format, adds 1 to the years and returns a string, verbalized as : {this} NewDate ({0})
String[] splitdata = d1.split("-");
int month = Integer.parseInt(splitdata[0]);
int day = Integer.parseInt(splitdata[1]);
int year = Integer.parseInt(splitdata[2]);
Calendar cal = Calendar.getInstance();
cal.set(year, month, day);
Date date = cal.getTime();
date.setYear(date.getYear() + 1);
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String s = dateFormat.format(date);
return s;
The rule is the following :
definitions
set 'variable1' to calendar NewDate (the transaction date of transaction) ;
if
the transaction date of transaction is today on the calendar
then
set the expiration date of account to variable1 ;
I enter transaction date like this : "2013-05-13", I was expecting : "2014-05-13" in the expiration date variable, but I get this 0181-10-05
Anyone can help ? Thanks.
Upvotes: 1
Views: 403
Reputation: 39
Your way of splitting the string is wrong as the year is entered as the 1st field and you are trying to obtain the date from this field, that is the order of the fields matter.
Essentially, your code should contain (notice the indexes):
int month=Integer.parseInt(splitdata[1]);
int day=Integer.parseInt(splitdata[2]);
int year=Integer.parseInt(splitdata[0]);
Upvotes: 2