@Override
 public void addNewSession(String sessionId) {
   // Get the realtime Date and time that the session has been created
   Date date = new Date();
   // Store the time session
   SessionTime.addOrUpdateSession(sessionId, date);
 }
  @Override
  public boolean validExpiredTimeSession(String sessionId) {
    boolean validSession = false;

    // Get the time of the session id
    Date initDate = SessionTime.getDateBySession(sessionId);
    // Get the realtime of the action
    Date endDate = new Date();

    if (getDiferenceBetweenDatesInMinutes(initDate, endDate)
        < SessionTime.getExpiredSessionTime()) {
      validSession = true;
      updateSessionTime(sessionId, endDate);
    } else {
      removeSessionTime(sessionId);
    }

    return validSession;
  }
  private double getDiferenceBetweenDatesInMinutes(Date initDate, Date endDate) {
    // By default return a number mayor than the expired session
    long totalMinutos = SessionTime.getExpiredSessionTime() + 1;

    if (initDate != null) {
      // Calculate the session time difference
      totalMinutos = modDates(initDate, endDate);
    }

    return totalMinutos;
  }
 protected void updateSessionTime(String sessionId, Date date) {
   SessionTime.addOrUpdateSession(sessionId, date);
 }
 @Override
 public void removeSessionTime(String sessionId) {
   // Remove the session
   SessionTime.removeSession(sessionId);
 }