Code example for Date

Methods: getTime

0
 
  public static long getTimeFromString(String time) {
    SimpleDateFormat format = new SimpleDateFormat(dateFormatString);
    try { 
      Date date = format.parse(time);
      return date.getTime();
    } catch (Exception e) {
      throw new RuntimeException(e);
    } 
  } 
 
  public static Date getDateFromString(String dateString) {
    SimpleDateFormat format = new SimpleDateFormat(dateFormatString);
    try { 
      Date date = format.parse(dateString);
      return date;
    } catch (Exception e) {
      throw new RuntimeException(e);
    } 
  }