Ejemplo n.º 1
0
  @Override
  public void startTask() {
    long sleep = new Random().nextInt(100) * 1000;
    cdate = System.currentTimeMillis();
    Date date = new Date(cdate);
    logger.info("开始任务 :TaskId=" + taskId + "\tcdate=" + date.toString() + " \tsleep=" + sleep);
    try {
      Thread.sleep(sleep);
      long now = System.currentTimeMillis();
      int threadCount = works.getActiveCount();
      logger.info(
          "完成任务:TaskId="
              + taskId
              + "\tRealy = "
              + (cdate + sleep - now)
              + "\tsleep="
              + sleep / 1000
              + "sec\tthreadCount="
              + threadCount);
    } catch (InterruptedException e) {
      logger.info("任务打断:TaskId=" + taskId + "\tcdate=" + date.toString());
    } catch (Exception e1) {

    }
  }
Ejemplo n.º 2
0
  public boolean editTask(
      String oldTitle, String title, String priority, String due_date, String created_at) {
    ContentValues values = new ContentValues();
    values.put(TaskEntry.COLUMN_NAME_TITLE, title);
    values.put(TaskEntry.COLUMN_NAME_PRIORITY, priority);
    Date date = null;
    try {
      if (due_date.indexOf("-") > 0) {
        date = new SimpleDateFormat("yyyy-MM-dd").parse(due_date);
      } else {
        date = new SimpleDateFormat("yyyy/MM/dd").parse(due_date);
      }
    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } // like "HH:mm" or just "mm", whatever you want
    String formattedDate = null;
    String newdate = date.toString();
    if (date.toString().indexOf("-") > 0) {
      formattedDate = new SimpleDateFormat("yyyy-MM-dd").format(date);
    } else {
      formattedDate = new SimpleDateFormat("yyyy/MM/dd").format(date);
    }

    values.put(TaskEntry.COLUMN_NAME_DUE_DATE, formattedDate);
    values.put(TaskEntry.COLUMN_NAME_CREATED, created_at);
    long updateId =
        database.update(
            TaskEntry.TABLE_NAME,
            values,
            TaskEntry.COLUMN_NAME_TITLE + "=" + "\"" + oldTitle + "\"",
            null);
    return true;
  }
Ejemplo n.º 3
0
  /**
   * Stirng representation for the authorization object.
   *
   * @return A String representation for the authorization object which has all the field names and
   *     values
   */
  public String toString() {
    String s = "";

    if (authorizationPK != null) s += authorizationPK.toString();

    s += "\nIs Active Now: ";
    if (isActiveNow != null) s += isActiveNow ? "Y" : "N";

    s += "\nGrant Authorization: ";
    if (grantAuthorization != null) s += grantAuthorization;

    s += "\nModified By: ";
    if (modifiedBy != null) s += modifiedBy;

    s += "\nModified Date: ";
    if (modifiedDate != null) s += modifiedDate.toString();

    s += "\nDo Function: ";
    if (doFunction != null) s += doFunction;

    s += "\nEffective Date: ";
    if (effectiveDate != null) s += effectiveDate.toString();

    s += "\nExpiration Date: ";
    if (expirationDate != null) s += expirationDate;

    return s;
  }
Ejemplo n.º 4
0
 /** Test the Date the feature was designed for (http://en.wikipedia.org/wiki/Year_2038_problem) */
 @Test
 public void testParseCaLatestValidDateTime() {
   LOG.trace(">testParseCaLatestValidDateTime");
   final String bug2038Hex = "80000000";
   LOG.info("bug2038Hex: " + bug2038Hex);
   final String bug2038Iso =
       FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ssZZ", TimeZone.getTimeZone("UTC"))
           .format(Long.parseLong("80000000", 16) * 1000);
   LOG.info("bug2038Iso: " + bug2038Iso);
   final Date bug2038HexDate = ValidityDate.parseCaLatestValidDateTime(bug2038Hex);
   LOG.info("bug2038HexDate: " + bug2038HexDate);
   final Date bug2038IsoDate = ValidityDate.parseCaLatestValidDateTime(bug2038Iso);
   LOG.info("bug2038IsoDate: " + bug2038IsoDate);
   Assert.assertEquals(
       "The two date formats should yield the same Date!", bug2038HexDate, bug2038IsoDate);
   // Test now also
   final Date now = new Date();
   LOG.info("now:        " + now);
   final String nowIso =
       FastDateFormat.getInstance(ValidityDate.ISO8601_DATE_FORMAT, TimeZone.getTimeZone("UTC"))
           .format(now);
   LOG.info("nowIso:     " + nowIso);
   final Date nowIsoDate = ValidityDate.parseCaLatestValidDateTime(nowIso);
   LOG.info("nowIsoDate: " + nowIsoDate);
   // Compare as strings since we will loose milliseconds in the conversion to ISO8601 format
   Assert.assertEquals(
       "Unable to parse current time correctly!", now.toString(), nowIsoDate.toString());
   // Test unhappy path (return of default value)
   final Date defaultIsoDate = ValidityDate.parseCaLatestValidDateTime("COFFEE");
   Assert.assertEquals(
       "Default value not returned when invalid date-time specified!",
       new Date(Long.MAX_VALUE).toString(),
       defaultIsoDate.toString());
   LOG.trace("<testParseCaLatestValidDateTime");
 }
 /**
  * Cursor to timer.
  *
  * @param c the c
  * @return the timer´
  * @author RayBa
  * @date 07.04.2013
  */
 private Timer cursorToTimer(Cursor c) {
   String name = c.getString(c.getColumnIndex(ChannelTbl.NAME));
   long channelID = c.getLong(c.getColumnIndex(ChannelTbl.CHANNEL_ID));
   String epgTitle =
       !c.isNull(c.getColumnIndex(EpgTbl.TITLE))
           ? c.getString(c.getColumnIndex(EpgTbl.TITLE))
           : name;
   long epgStart = c.getLong(c.getColumnIndex(EpgTbl.START));
   long epgEnd = c.getLong(c.getColumnIndex(EpgTbl.END));
   DVBViewerPreferences prefs = new DVBViewerPreferences(getSherlockActivity());
   int epgBefore = prefs.getPrefs().getInt(DVBViewerPreferences.KEY_TIMER_TIME_BEFORE, 5);
   int epgAfter = prefs.getPrefs().getInt(DVBViewerPreferences.KEY_TIMER_TIME_AFTER, 5);
   Date start = epgStart > 0 ? new Date(epgStart) : new Date();
   Date end = epgEnd > 0 ? new Date(epgEnd) : new Date(start.getTime() + (1000 * 60 * 120));
   Log.i(ChannelList.class.getSimpleName(), "start: " + start.toString());
   Log.i(ChannelList.class.getSimpleName(), "end: " + end.toString());
   start = DateUtils.addMinutes(start, 0 - epgBefore);
   end = DateUtils.addMinutes(end, epgAfter);
   Timer timer = new Timer();
   timer.setTitle(epgTitle);
   timer.setChannelId(channelID);
   timer.setChannelName(name);
   timer.setStart(start);
   timer.setEnd(end);
   timer.setTimerAction(
       prefs.getPrefs().getInt(DVBViewerPreferences.KEY_TIMER_DEF_AFTER_RECORD, 0));
   return timer;
 }
Ejemplo n.º 6
0
  @Override
  public String toString() {
    StringBuilder b = new StringBuilder();

    b.append("currency: ").append(currency).append('\n');
    b.append("bankId: ").append(bankId).append('\n');
    b.append("accountId: ").append(accountId).append('\n');
    b.append("accountType: ").append(accountType).append('\n');
    b.append("dateStart: ").append(dateStart.toString()).append('\n');
    b.append("dateEnd: ").append(dateEnd.toString()).append('\n');
    b.append("ledgerBalance: ").append(ledgerBalance.toString()).append('\n');
    b.append("ledgerBalanceDate: ").append(ledgerBalanceDate.toString()).append('\n');

    if (availBalance != null) {
      b.append("availBalance: ").append(availBalance.toString()).append('\n');
    }

    if (availBalanceDate != null) {
      b.append("availBalanceDate: ").append(availBalanceDate.toString()).append('\n');
    }

    for (ImportTransaction t : getTransactions()) {
      b.append(t.toString()).append('\n');
    }

    return b.toString();
  }
Ejemplo n.º 7
0
  public static boolean checkDate(String date1, String date2) {

    Date date11 = DateUtil.str2Date(date1, "yyyy-MM-dd HH:mm:ss"); // 起始时间

    Date date22 = DateUtil.str2Date(date2, "yyyy-MM-dd HH:mm:ss"); // 终止时间

    Calendar scalendar = Calendar.getInstance();
    scalendar.setTime(date11); // 起始时间

    Calendar ecalendar = Calendar.getInstance();
    ecalendar.setTime(date22); // 终止时间

    Calendar calendarnow = Calendar.getInstance();

    System.out.println(date11.toString());
    System.out.println(date22.toString());
    System.out.println(scalendar.toString());
    System.out.println(ecalendar.toString());
    System.out.println(calendarnow.toString());

    if (calendarnow.after(scalendar) && calendarnow.before(ecalendar)) {
      return true;
    } else {
      return false;
    }
  }
Ejemplo n.º 8
0
 /**
  * Reading one email at a time. Using Item ID of the email. Creating a message data map as a
  * return value.
  */
 public Map readEmailItem(ItemId itemId, boolean doDelete) {
   Map messageData = new HashMap();
   try {
     Item itm = Item.bind(exchangeService, itemId, PropertySet.FirstClassProperties);
     EmailMessage emailMessage = EmailMessage.bind(exchangeService, itm.getId());
     if (doDelete) {
       System.out.println("deleting item: " + itm.getSubject());
       itm.delete(DeleteMode.HardDelete);
       emailMessage.delete(DeleteMode.HardDelete);
     } else {
       messageData.put("emailItemId", emailMessage.getId().toString());
       messageData.put("subject", emailMessage.getSubject());
       messageData.put("fromAddress", emailMessage.getFrom().getAddress().toString());
       messageData.put("senderName", emailMessage.getSender().getName().toString());
       Date dateTimeCreated = emailMessage.getDateTimeCreated();
       messageData.put("SendDate", dateTimeCreated.toString());
       Date dateTimeReceived = emailMessage.getDateTimeReceived();
       messageData.put("ReceivedDate", dateTimeReceived.toString());
       messageData.put("Size", emailMessage.getSize() + "");
       messageData.put("emailBody", emailMessage.getBody().toString());
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return messageData;
 }
Ejemplo n.º 9
0
  public LinkedHashMap<String, int[]> getFeedback() {
    DBCursor obj = coll.find();
    String current_date = "0";
    String prev_date = "0";
    int counter = 0;
    int[] count = new int[4];
    ;
    while (obj.hasNext()) {

      DBObject dbObj = obj.next();
      prev_date = current_date;
      Date d = (Date) dbObj.get("Order_Date");

      current_date =
          (String) d.toString().substring(4, 10) + " " + (String) d.toString().substring(24);
      //
      //            int prev_excellent = 0;
      //            int prev_good = 0;
      //            int prev_average = 0;
      //            int prev_bad=0;

      if (dbObj.get("Feedback").equals("Excellent")) {
        count[0] = (Integer) dbObj.get("feedback_count");

        data.put(current_date, count);
        counter++;
      }
      if (dbObj.get("Feedback").equals("Good")) {
        count[1] = (Integer) dbObj.get("feedback_count");

        data.put(current_date, count);
        counter++;
      }
      if (dbObj.get("Feedback").equals("Average")) {
        count[2] = (Integer) dbObj.get("feedback_count");

        data.put(current_date, count);
        counter++;
      }
      if (dbObj.get("Feedback").equals("Bad")) {
        count[3] = (Integer) dbObj.get("feedback_count");

        data.put(current_date, count);
        counter++;
      }

      if (counter % 4 == 0) {
        //    System.out.println(current_date);
        //    System.out.println(count[0]);
        //    System.out.println(count[1]);
        //    System.out.println(count[2]);
        //    System.out.println(count[3]);
        data.put(current_date, count);
        count = new int[4];
      }
    }

    return data;
  }
Ejemplo n.º 10
0
 public void printSluitTijden() {
   System.out.println(
       this.verbinding.getNaam()
           + " is niet toegankelijk vanaf "
           + vanaf.toString()
           + " tot "
           + tot.toString());
 }
Ejemplo n.º 11
0
  /* (non-Javadoc)
   * @see org.openiam.idm.srvc.auth.login.LoginDAO#findInactiveUsers(int, int)
   */
  public List<Login> findInactiveUsers(int startDays, int endDays, String managedSysId) {
    log.debug("findInactiveUsers called.");
    log.debug("Start days=" + startDays);
    log.debug("End days=" + endDays);

    boolean start = false;
    long curTimeMillis = System.currentTimeMillis();
    Date startDate = new Date(curTimeMillis);
    Date endDate = new Date(curTimeMillis);

    StringBuilder sql =
        new StringBuilder(
            " from org.openiam.idm.srvc.auth.dto.Login l where "
                + " l.id.managedSysId = :managedSys and ");

    if (startDays != 0) {
      sql.append(" l.lastLogin <= :startDate ");
      start = true;

      Calendar c = Calendar.getInstance();
      c.setTime(startDate);
      c.add(Calendar.DAY_OF_YEAR, (-1 * startDays));
      startDate.setTime(c.getTimeInMillis());

      log.debug("starDate = " + startDate.toString());
    }
    if (endDays != 0) {
      if (start) {
        sql.append(" and ");
      }
      sql.append(" l.lastLogin >= :endDate ");

      Calendar c = Calendar.getInstance();
      c.setTime(endDate);
      c.add(Calendar.DAY_OF_YEAR, (-1 * endDays));
      endDate.setTime(c.getTimeInMillis());

      log.debug("endDate = " + endDate.toString());
    }

    Session session = sessionFactory.getCurrentSession();
    Query qry = session.createQuery(sql.toString());

    qry.setString("managedSys", managedSysId);

    if (startDays != 0) {
      qry.setDate("startDate", startDate);
    }
    if (endDays != 0) {
      qry.setDate("endDate", endDate);
    }

    List<Login> results = (List<Login>) qry.list();
    if (results == null) {
      return (new ArrayList<Login>());
    }
    return results;
  }
Ejemplo n.º 12
0
  public String getElapsedTime() {
    StringBuilder res = new StringBuilder();
    Date thisTime = new Date();
    long elapsed = thisTime.getTime() - lastTime.getTime();

    res.append("Last time ").append(lastTime.toString());
    res.append(" now ").append(thisTime.toString());
    res.append(" Elapsed ").append((new Long(elapsed)).toString()).append("ms");

    lastTime = thisTime;
    return res.toString();
  }
Ejemplo n.º 13
0
 public static void main(String[] args) throws Exception {
   SIGNAL today, yesterday;
   System.out.println("current day " + currentDay.toString());
   System.out.println("prev day " + priorDay.toString());
   for (ListB ticker : ListB.values()) {
     today = checkForSignal(ticker.toString(), currentDay);
     yesterday = checkForSignal(ticker.toString(), priorDay);
     if (today != SIGNAL.NONE) {
       if (yesterday == SIGNAL.NONE) System.out.println(today + " , " + ticker);
     }
   }
 }
Ejemplo n.º 14
0
 @Override
 public String getText(Object element) {
   if (element instanceof RepositoryProvider) {
     return ((RepositoryProvider) element).getID();
   } else if (element instanceof IFileRevision) {
     Date date = new Date(((IFileRevision) element).getTimestamp());
     return date.toString();
   } else if (element instanceof IFileState) {
     Date date = new Date(((IFileState) element).getModificationTime());
     return date.toString();
   }
   return super.getText(element);
 }
Ejemplo n.º 15
0
 @PostConstruct
 public void init() {
   hotels.clear();
   events.clear();
   flights.clear();
   flights2.clear();
   flights3.clear();
   System.out.println("FISRT VISIT? " + firstPageVisit);
   // --e poi aggiornare un altra data che indica dinamicamente la prima delle due e usarla come
   // min date della seconda, piu un controllo server
   System.out.println("Date: " + currDate.toString());
   System.out.println("Date limit: " + dateLimit.toString());
 }
Ejemplo n.º 16
0
  @Test
  @RunAsClient
  public void testDate() throws Exception {
    URL wsdlURL = new URL(baseURL + "/MyService?wsdl");
    QName qname = new QName("http://date.jaxws.ws.test.jboss.org/", "MyService");
    Service service = Service.create(wsdlURL, qname);
    Endpoint port = service.getPort(Endpoint.class);

    Date date = new Date();

    Date response = port.echoDate(date);
    assertEquals(date.toString(), response.toString());
  }
    @Override
    public void run() {
      CreateCustomerProfileResponse response = null;
      CreateCustomerPaymentProfileResponse paymentProfileResponse = null;

      try {
        response =
            (CreateCustomerProfileResponse)
                CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail());
        paymentProfileResponse =
            (CreateCustomerPaymentProfileResponse)
                CreateCustomerPaymentProfile.run(
                    apiLoginId, transactionKey, response.getCustomerProfileId());
      } catch (Exception e) {
        System.out.println("Failure in CIM calls.");
        System.out.println(e.getMessage());
        return;
      }

      try {
        Date dt1 = new Date();
        System.out.println(
            "============================================================================");
        System.out.println("chargeResponse Dt1: + " + dt1.toString());

        if ((response.getCustomerProfileId() != null)
            && (paymentProfileResponse.getCustomerPaymentProfileId() != null)) {
          CreateTransactionResponse chargeResponse =
              (CreateTransactionResponse)
                  ChargeCustomerProfile.run(
                      apiLoginId,
                      transactionKey,
                      response.getCustomerProfileId(),
                      paymentProfileResponse.getCustomerPaymentProfileId(),
                      getAmount());
        } else {
          System.out.println("NULL PROFILE IDS.");
        }

        Date dt2 = new Date();
        System.out.println("chargeResponse Dt2: + " + dt2.toString());

        long difference = dt2.getTime() - dt1.getTime();
        System.out.println("chargeResponse Diff: " + difference / 1000);
        System.out.println(
            "============================================================================");
      } catch (Exception e) {
        System.out.println("Failure in charge customer profile call:");
        System.out.println(e.getMessage());
      }
    }
Ejemplo n.º 18
0
  /**
   * Formats a date object for use in a mysql statement as a string.
   *
   * @param d - the date object to be converted
   * @return Stringified date in format shown below
   */
  public String formatAsMySQLDate(Date d) {
    String convertedDate = null;

    if (d == null || d.toString().length() == 0) {
      return "";
    }
    if (d.toString().length() <= RsDate.MySQLDateFormat.length()) {
      convertedDate = new SimpleDateFormat("yyyy-MM-dd").format(d);
    } else {
      convertedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(d);
    }

    return convertedDate;
  }
Ejemplo n.º 19
0
  @org.testng.annotations.Test
  public void testDate() {
    Date d = new Date();
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    format.setCalendar(new GregorianCalendar(new SimpleTimeZone(0, "GMT")));
    String formattedDate = format.format(d);

    String serialized = JSON.serialize(d);
    assertEquals("{ \"$date\" : \"" + formattedDate + "\"}", serialized);

    Date d2 = (Date) JSON.parse(serialized);
    assertEquals(d.toString(), d2.toString());
    assertTrue(d.equals(d2));
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_information_flow);
    ButterKnife.bind(this);

    collegeField.addTextChangedListener(mTextWatcher);
    graduationDateField.addTextChangedListener(mTextWatcher);

    ParseUser user = ParseUser.getCurrentUser();
    String collegeText = user.getString(ParseConstants.KEY_COLLEGE_ATTENDED);
    Date graduationText = user.getDate(ParseConstants.KEY_GRADUATION_DATE);
    String employerText = user.getString(ParseConstants.KEY_EMPLOYER_NAME);
    Date examText = user.getDate(ParseConstants.KEY_EXAM_DATE);

    if (collegeText != null) {
      collegeField.setText(collegeText);
    }
    if (graduationText != null) {
      try {
        String currentDate = graduationText.toString(); // Tue May 01 00:00:00 EDT 2018
        SimpleDateFormat simpleDateFormat =
            new SimpleDateFormat("EEEE MMM dd HH:mm:ss z yyyy", Locale.US);
        Date tempDate = simpleDateFormat.parse(currentDate);
        SimpleDateFormat outputDateFormat = new SimpleDateFormat("MM/dd/yy", Locale.US);
        graduationDateField.setText(outputDateFormat.format(tempDate));
      } catch (ParseException ex) {
        Log.e(TAG, "Error converting dates");
        Log.e(TAG, graduationText.toString());
      }
    }
    if (employerText != null) {
      employerNameField.setText(employerText);
    }
    if (examText != null) {
      try {
        Log.d(TAG, examText.toString());
        String currentDate = examText.toString(); // Tue May 01 00:00:00 EDT 2018
        SimpleDateFormat simpleDateFormat =
            new SimpleDateFormat("EEEE MMM dd HH:mm:ss z yyyy", Locale.US);
        Date tempDate = simpleDateFormat.parse(currentDate);
        SimpleDateFormat outputDateFormat = new SimpleDateFormat("MM/dd/yy", Locale.US);
        examDateField.setText(outputDateFormat.format(tempDate));
      } catch (ParseException ex) {
        Log.e(TAG, "Error converting dates");
        Log.e(TAG, examText.toString());
      }
    }
  }
Ejemplo n.º 21
0
 /** @param args */
 public static void main(String[] args) {
   // TODO Auto-generated method stub
   Repairorder order = RepairOrderSvc.getInstance().findById(30);
   Date startDate = order.getStartdate();
   System.out.println(startDate.toGMTString());
   System.out.println(startDate.toLocaleString());
   System.out.println(startDate.toString());
   Date date = new Date();
   System.out.println(date.toGMTString());
   System.out.println(date.toLocaleString());
   System.out.println(date.toString());
   System.out.println(date.toGMTString());
   System.out.println(date.toLocaleString());
   System.out.println(date.toString());
 }
Ejemplo n.º 22
0
 public static void test(Date date) {
   String isodate = null;
   System.out.println("----------------------------------");
   try {
     System.out.println(">> " + date.toString() + " [" + date.getTime() + "]");
     isodate = getIsoDate(date);
     System.out.println(">> " + isodate);
     date = parse(isodate);
     System.out.println(">> " + date.toString() + " [" + date.getTime() + "]");
   } catch (InvalidDateException ex) {
     System.err.println(isodate + " is invalid");
     System.err.println(ex.getMessage());
   }
   System.out.println("----------------------------------");
 }
Ejemplo n.º 23
0
 /**
  * Get available timeslots based on passed parameters
  *
  * @param fromDate
  * @param toDate
  * @param appointmentType
  * @param location
  * @param provider
  * @param limit
  * @return
  */
 public List<TimeSlot> getTimeSlots(
     Date fromDate,
     Date toDate,
     String appointmentType,
     String location,
     String provider,
     String limit) {
   String charset = "UTF-8";
   ObjectMapper m = new ObjectMapper();
   List<TimeSlot> timeSlots = new ArrayList<TimeSlot>();
   TimeSlot timeSlot;
   try {
     DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
     String query =
         String.format(
             "appointmentscheduling/timeslot?fromDate=%s"
                 + "&toDate=%s&appointmentType=%s"
                 + "&location=%s&provider=%s"
                 + "&limit=%s&v=full",
             URLEncoder.encode(df.format(fromDate), charset),
             URLEncoder.encode(df.format(toDate), charset),
             URLEncoder.encode(appointmentType, charset),
             URLEncoder.encode(location, charset),
             URLEncoder.encode(provider, charset),
             URLEncoder.encode(limit, charset));
     logger.debug(query);
     JsonNode rootNode = m.readTree(RestCall.getRequestGet(query));
     JsonNode results = rootNode.get("results");
     for (JsonNode result : results) {
       String uuid = result.path("uuid").textValue();
       Date startDate = ISO8601DateParser.parse(result.path("startDate").textValue());
       Date endDate = ISO8601DateParser.parse(result.path("endDate").textValue());
       String appBlockUuid = result.path("appointmentBlock").path("uuid").textValue();
       AppointmentBlock appointmentBlock = new AppointmentBlock();
       appointmentBlock.setUuid(appBlockUuid);
       timeSlot = new TimeSlot(appointmentBlock, startDate, endDate);
       timeSlot.setUuid(uuid);
       timeSlots.add(timeSlot);
       System.out.println(startDate.toString() + " " + endDate.toString());
     }
     return timeSlots;
   } catch (Exception ex) {
     logger.info("Some Error occured while getting timeSlots");
     logger.error("\n ERROR Caused by\n", ex);
     ex.printStackTrace();
     return timeSlots;
   }
 }
Ejemplo n.º 24
0
 public Item(
     String source,
     String link,
     String title,
     String description,
     Date datePublication,
     List enclosure) {
   try {
     this.uri = link;
     values = new ArrayList<Prop>();
     values.add(new Prop(RSS.link, link, true, false));
     values.add(new Prop(RSS.title, title));
     values.add(new Prop(RSS.description, Jsoup.parse(description).text()));
     if (datePublication != null) {
       values.add(new Prop(RSS.getURI() + "pubDate", datePublication.toString()));
       values.add(
           new Prop(RSS.getURI() + "pubDateTime", Long.toString(datePublication.getTime())));
     }
     for (Object o : enclosure) {
       SyndEnclosureImpl e = (SyndEnclosureImpl) o;
       values.add(new Prop(RSS.image, e.getUrl(), true, false));
     }
     values.add(new Prop("http://purl.org/rss/1.0/source", source, false, false));
   } catch (NullPointerException e) {
     logger.error(e);
   }
 }
Ejemplo n.º 25
0
  private void dumpDocument(int docNum, Document doc) throws IOException {

    outputLn();
    outputLn("Document " + docNum);

    if (doc == null) {
      outputLn("    deleted");
      return;
    }

    // note: only stored fields will be returned
    for (Fieldable field : doc.getFields()) {
      String fieldName = field.name();

      boolean isDate = "l.date".equals(fieldName);

      outputLn("    Field [" + fieldName + "]: " + field.toString());
      String[] values = doc.getValues(fieldName);
      if (values != null) {
        int i = 0;
        for (String value : values) {
          output("         " + "(" + i++ + ") " + value);
          if (isDate) {
            try {
              Date date = DateTools.stringToDate(value);
              output(" (" + date.toString() + " (" + date.getTime() + "))");
            } catch (java.text.ParseException e) {
              assert false;
            }
          }
          outputLn();
        }
      }
    }
  }
  /** REST API call to sentiment 140 */
  @Override
  public void execute(Tuple tuple, BasicOutputCollector collector) {
    startTime = System.currentTimeMillis();
    List<Object> otherFields = Lists.newArrayList(tuple.getValues());
    int currentCounter = (Integer) otherFields.get(0);
    int currentSentiment = (Integer) otherFields.get(1);
    Date tempDate = (Date) otherFields.get(2); // 0: counter, 1: //
    // sentement_Id, //
    // 2:Date_object
    Integer isAnomalous = (Integer) otherFields.get(3);

    List<TweetTransferEntity> tweetList = (List<TweetTransferEntity>) otherFields.get(4);

    int aggregation_factor = 123;

    TweetJDBCTemplate tweetJdbcTemplate =
        TweetJDBCTemplateConnectionPool.getTweetJDBCTemplate("test", configFile);

    List<AnomalyTableObject> anomalies = new ArrayList<AnomalyTableObject>(0);

    if (isAnomalous == 1 || isAnomalous == 2) {

      // for (TweetTransferEntity tweetTransferEntity : tweetList) {
      // AnomalyTableObject anomaly = new AnomalyTableObject();
      // anomaly.setQuery_id(2);
      // anomaly.setSentiment(currentSentiment);
      // anomaly.setTimestamp(tweetTransferEntity.getTimestamp() );
      //
      // anomaly.setTweet_id(tweetTransferEntity.getTimestamp());
      // anomaly.setValue(currentCounter);
      // anomaly.setWindow_length(0);
      // anomaly.setAggregation(aggregation_factor);
      // anomaly.setNote(tempDate.toString());
      //
      // anomalies.add(anomaly);
      // }
      // tweetJdbcTemplate.insertAnomalies(anomalies);

      long current_timestamp = tempDate.getTime() / 1000;
      long previousAggregated_timestamp =
          AggregateUtilityFunctions.minusMinutesToDate(15, tempDate).getTime() / 1000;
      AnomalyTableObject anomaly = new AnomalyTableObject();
      anomaly.setQuery_id(2);
      anomaly.setSentiment(currentSentiment);
      anomaly.setTimestamp(tempDate.getTime() / 1000);

      anomaly.setTweet_id(current_timestamp);
      anomaly.setValue(currentCounter);
      anomaly.setWindow_length(0);
      anomaly.setAggregation(aggregation_factor);
      anomaly.setNote(tempDate.toString());

      tweetJdbcTemplate.insertAnomaly_test(
          anomaly, previousAggregated_timestamp, current_timestamp);
    }

    long elapsedTime = System.currentTimeMillis() - startTime;

    LOG.info("Time to process is::" + elapsedTime / 1000 + " for size:: " + tweetList.size());
  }
 @Override
 public String toString() {
   Date timestampDate = new Date(mTimestamp * 1000);
   return "AlarmInstance{"
       + "mId="
       + mId
       + ", mYear="
       + mYear
       + ", mMonth="
       + mMonth
       + ", mDay="
       + mDay
       + ", mHour="
       + mHour
       + ", mMinute="
       + mMinute
       + ", mLabel="
       + mLabel
       + ", mVibrate="
       + mVibrate
       + ", mRingtone="
       + mRingtone
       + ", mAlarmId="
       + mAlarmId
       + ", mLightuppiId="
       + mLightuppiId
       + ", mAlarmState="
       + mAlarmState
       + ", mTimestamp="
       + timestampDate.toString()
       + '}';
 }
 public void _controllerShowSwitches(CommandInterpreter ci) {
   Set<Long> sids = switches.keySet();
   StringBuffer s = new StringBuffer();
   int size = sids.size();
   if (size == 0) {
     ci.print("switches: empty");
     return;
   }
   Iterator<Long> iter = sids.iterator();
   s.append("Total: " + size + " switches\n");
   while (iter.hasNext()) {
     Long sid = iter.next();
     Date date = switches.get(sid).getConnectedDate();
     String switchInstanceName = ((SwitchHandler) switches.get(sid)).getInstanceName();
     s.append(
         switchInstanceName
             + "/"
             + HexString.toHexString(sid)
             + " connected since "
             + date.toString()
             + "\n");
   }
   ci.print(s.toString());
   return;
 }
Ejemplo n.º 29
0
 /**
  * For debugging
  *
  * @return a human readable description of the TriggerWrapper
  */
 public String getTriggerInfo() {
   return "TriggerInfo: "
       + ClusterCacheJobStore.generateKey(trigger.getKey())
       + "\nState: "
       + getTriggerStateName()
       + "\nFireringInstance: "
       + (fireingInstance == null ? "null" : fireingInstance)
       + "\nJobExecuting: "
       + jobExecuting
       + "\nFireTime: "
       + (fireTime == null ? "null" : fireTime.toString())
       + "\nScheduleTime: "
       + (scheduleTime == null ? "null" : scheduleTime.toString())
       + "\nRecovering: "
       + recovering;
 }
Ejemplo n.º 30
0
  public static int dateDifferenceLocal(String start_time) {

    SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy hh:mma");

    Date staart = new Date();

    try {
      staart = sdf.parse(start_time);
    } catch (ParseException e) {
      e.printStackTrace();
    }

    Date end = new Date();

    long diff = end.getTime() - staart.getTime();

    long diffSeconds = diff / 1000 % 60;
    long diffMinutes = diff / (60 * 1000); // % 60;
    long diffHours = diff / (60 * 60 * 1000) % 24;
    long diffDays = diff / (24 * 60 * 60 * 1000);

    //        Log.w("chuy", hoy.toString() + " today");
    Log.w("chuy", staart.toString() + " start");
    Log.w("chuy", diffMinutes + " minutes");

    return Math.round(diffMinutes);
  }