title: How can avoid if else statements and rewrite them into smaller and cleaner code?
body: <p>I am supposed to insert an argument by the form of yyyy""mm""dd, while using " / ", " . " or " - " as seperators. The programm identifies which seperator was used, the other functions are not relevant. However there are way too many if else statements that I am sure can be rewritten or replaced with cleaner code.
  Any suggestions?</p>
  
  <pre><code>static String[] weekDays = new String[] {
          "Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur"
  };
  
  enum weekDays {SUN,MON,TUES,WEDNES,THURS,FRI,SATUR};
  
  static void setCalendarDate(final Calendar cal, final String date, final String seperator) {
      final String[] splitDate = date.split(seperator);
      cal.set(parseInt(splitDate[0]), parseInt(splitDate[1]) - 1, parseInt(splitDate[2]));
  }
  
  public static void main(final String[] args) {
  
      final Calendar cal = Calendar.getInstance();
      if (args.length != 0) {
          if (args[0].contains("-")) {
              setCalendarDate(cal, args[0], "-");
          } else if (args[0].contains("/")) {
              setCalendarDate(cal, args[0], "/");
          } else if (args[0].contains(".")) {
              setCalendarDate(cal, args[0],".");
          }
      }
      final int weekDay = cal.get(Calendar.DAY_OF_WEEK);
      System.out.printf("%sday\n", weekDays[weekDay - 1]);
  }
  </code></pre>
  
  <p>}</p>