I wish to get 2018 replaced with 2014. Posting Year, which is currently having the 4/5/2018, must be changed to the purchase date of 4/5/2014 !! Please review the code:
String PostingPeriodIs= Jan 2014
String PostingPeriod= 05/04/2018
int lnthPostingPeriodIs = PostingPeriodIs.length();
int lnthPostingPeriod = PostingPeriod.length();
String Year=null , YearIs=null;
try {
Year= PostingPeriodIs.substring(lnthPostingPeriodIs-4);
YearIs=PostingPeriod.substring(lnthPostingPeriod-4);
System.out.println("Year is =========>"+Year);
System.out.println("Expected year is ==>"+YearIs);
}
catch (Exception ex) {
System.out.println("Exception in catchMethod");
ex.printStackTrace();
}
String PostingYear= PostingPeriod.replace(Year, YearIs);
uiDriver.webUIDriver.webDriver().findElement(By.xpath("//*[@id='trandate']")).sendKeys(PostingYear);