0

I am working on a callflow just now. Client needs to Date of Birth to be entered by their customers, the format they request it is entered is DDMMYYYY (8 Digits). This is simple to do within the GUI we use to develop callflows without any sort of scripting, other than a substring to match this entered DOB to the format they actually have stored in their DB.

However now the client wants us to account for potential errors in input from their customers.

So they want to account for DMMYY, DDMYY, DDMMYY AND DMMYYYY. Again the majority of this can be handled by the Editor and working on varDOBInput.toString().length==5, 6 whatever.

The problem is the first 2 DMMYY, DDMYY, both ==5. That is when I can't use the editor and I can only script this. When thinking about the script I am not even sure how I can do this using an if statement.

if(varDOBInput.toString().length==5) {}

Both inputs are going to be equal to 5, how can I get Java to differentiate from the two? Is it even possible, because the if statement is just going to follow until a result is matched and it will be with .length==5

I am very much a beginner at Java, I am probably being a bit optimistic by saying beginner.

khelwood
  • 55,782
  • 14
  • 81
  • 108
  • 1
    what about using a date formatter – Youcef LAIDANI Jul 20 '18 at 10:55
  • 1
    Ask your client what date 11111 should represent. Seems like your client is asking for magic. – khelwood Jul 20 '18 at 10:56
  • Dude. Neither Java, nor anything could do it. You, without programming but just with your mind, wouldn't be able to do it. It's impossible. It requires to be psychic. – kumesana Jul 20 '18 at 10:56
  • Thanks everyone. I didn't think it was possible and I have advised them of the possible false positives of ddmyy & dmmyy can bring but they seem very determined they can do this. To me they should not be bothering with accounting for errors in input, they request the customer to enter in a specific format, twice. Its very clear what format is required. – Russell Heaney Jul 20 '18 at 12:18

3 Answers3

0

No, you can’t do that. A two digit month could begin with the number 1 or 0 and a two digit day could end with the number 1 or 0.

So then 20299 could be February 2 or February 20. There’s no way of knowing.

Patrick Parker
  • 4,863
  • 4
  • 19
  • 51
0

I don't think you will be able to differentiate For example the input 11118, will this be parsed as 11-Jan-2018 or 1-Nov-2018? You just need to try to parse it as one and if that fails try the other, there's no way of knowing what the user means if they typed a value parsable with both DMMYY and DDMYY

Muji
  • 531
  • 6
  • 10
0

As others have said its impossible to do that as there are many situations in which you have more than one valid date that can be parsed from given string, my suggestion is to talk with client and suggest him to use some separator(/, -, . etc.), or even different input fields for date, also most modern GUI toolkits now have built in DatePicker which might be even better option.

FilipRistic
  • 2,661
  • 4
  • 22
  • 31