0

i have the below method signature in which there are two different parameters out of which there is one parameter named dateStr, now inside dateStr variable there can be multiple date formats for example following are the values that can be inside dateStr variable

21/02/2014
05/25/2014
05/12/16
2016/12/26  (YYYY/MM-dd)   ****//check this pattern format  *******
2014-JAN-04 (YYYY-MMM-dd)   ****//check this pattern format ********

below is the method code signature

public java.util.Date extractDate(String dateStr, String dateType) {
}

now for the patterns like

(YYYY/MM-dd) and (YYYY-MMM-dd) i have two handle these two patterns specially ignoring the rest other patterns so what i have come up with these if block

if (!dateStr.equals("YYYY-MM-dd" && "YYYY/MM-dd")) {
    // code
}
else
{
//***** handle YYYY-MM-dd && YYYY/MM-dd *** here 
}

please advise is it correct way or i can add any regex here also

sss
  • 161
  • 1
  • 1
  • 13

0 Answers0