code: public static Date convertDate(Object input) {
  
          Date result;
          if (input instanceof Date) {
              result = (Date)input;
          } else if (input instanceof Long) {
              result = new Date(((Long)input).longValue());
          } else {
              String str = String.valueOf(input);
              try {
                  // treat the input as a String
                  long l = Long.parseLong(str);
                  result = new Date(l);
              } catch (NumberFormatException e) {
                  try {
                      // try to parse String as a Date
                      result = DateFormat.getDateInstance().parse(str);
                  } catch (ParseException e1) {
                      result = null;
                  }
                  if (result == null) {
                      // use default date if parsing fails
                      result = new Date(0);
                  }
              }
          }
          return result;
      }
docs: Returns a Date created from an Object.<p>
  
  <ul>
  <li>The Object is first checked if it is a {@link Date} already, if so it is casted and returned unchanged.
  <li>If not, the input is checked if it is a {@link Long}, and if so the Date is created from the Long value.
  <li>If it's not a Date and not a Long, the Object is transformed to a String and then it's tried
  to parse a Long out of the String.
  <li>If this fails, it is tried to parse as a Date using the
  default date formatting.
  <li>If this also fails, a new Date is returned that has been initialized with 0.<p>
  </ul>
  
  @param input the Object to create a Date from
  
  @return a Date created from the given Object