Package com.webobjects.foundation

Examples of com.webobjects.foundation.NSTimestamp


      // rather than the last task.
      ec = newEditingContext();
      ec.lock();
      try {
        TaskInfo taskInfo = (TaskInfo) ec.faultForGlobalID(_taskInfoGID, ec);
        taskInfo.setStartTime(new NSTimestamp(startTime));
        taskInfo.setDuration(Long.valueOf(taskInfo.endTime().getTime() - startTime));
        ec.saveChanges();
      } finally {
        ec.unlock();
      }
View Full Code Here


  public Day weeksFromNow(int weeks) {
    int days = weeks * 7;
    Calendar cal = startCalendar();
    cal.add(Calendar.DATE, days);
    return new Day(new NSTimestamp(cal.getTime()));
  }
View Full Code Here

        super(context);
    _updateTime();
    }
 
  public void _updateTime() {
    _now = new NSTimestamp();
  }
View Full Code Here

      TaskInfo taskInfo = (TaskInfo) ec.faultForGlobalID(_taskInfoGID, ec);
      _totalCount = taskInfo.countResultItems().longValue();
     
      // Task start time
      // This is a demo, so we are going to replace the prime processing times with the factorial processing times
      taskInfo.setStartTime(new NSTimestamp(startTime));
     
      // For demo purposes we will use batches and EC recycling, which would be common for processing huge data sets
      ERXFetchSpecification<ResultItem> fs = taskInfo.fetchSpecificationForResultItems();
     
      // Batch iterator
      ERXFetchSpecificationBatchIterator fsIterator = new ERXFetchSpecificationBatchIterator(fs, ec);

      // Loop for a period of time
      while (fsIterator.hasNext() && !_isStopped) {
        @SuppressWarnings("unchecked")
        NSArray<ResultItem> batch = fsIterator.nextBatch();
       
        for (ResultItem resultItem : batch) {
          resultItem.setWorkflowState(ResultItem.WORKFLOW_CHECKING_FACTORIAL);
          performFactorialProcessing(resultItem);
          resultItem.setWorkflowState(ResultItem.WORKFLOW_PROCESSING_COMPLETE);

          ec.saveChanges();
         
         
          _elapsedTime = System.currentTimeMillis() - startTime;
         
          // Update progress variables
          _countCompleted++;
          _percentComplete = (double)(_countCompleted) / (double)_totalCount;
          _status = wholeNumberFormatter.format(_countCompleted) + " numbers checked for factorial proximity";
         
          if (_isStopped) {
            break;
          }

        }
       
        // Swap in a fresh EC for the next batch to help with memory management
        EOEditingContext freshEC = newEditingContext();
        ec.unlock();
        ec = freshEC;
        freshEC.lock();
       
        fsIterator.setEditingContext(ec);
       
        // We need to refault taskInfo into the new EC after swapping
        taskInfo = (TaskInfo) ec.faultForGlobalID(_taskInfoGID, ec);
       
      }
     
      // Complete the stats
      taskInfo.setEndTime(new NSTimestamp());
      taskInfo.setWorkflowState(TaskInfo.WORKFLOW_PROCESSING_COMPLETE);
     
      long duration = taskInfo.endTime().getTime() - taskInfo.startTime().getTime();
      taskInfo.setDuration(duration);
     
View Full Code Here

    monthCalendar.set(Calendar.MONTH, _month - 1);
    return monthCalendar;
  }

  public NSTimestamp monthTimestamp() {
    NSTimestamp calendarTimestamp = DateUtils.timestamp(_year, _month, 1, 0, 0, 0, 0);
    return calendarTimestamp;
  }
View Full Code Here

   *
   * @return visible date range
   */
  public DateRange visibleDateRange() {
    NSArray<Week> weeks = weekObjects();
    NSTimestamp startDate = weeks.objectAtIndex(0).getStartTime();
    NSTimestamp endDate = weeks.lastObject().getEndTime();
    return new DateRange(startDate, endDate);
  }
View Full Code Here

    public static long differenceByYear(NSTimestamp t1, NSTimestamp t2) {
        return compareDatesInCommonEra(t1, t2, Calendar.YEAR);
    }

    public static NSTimestamp firstDateInSameWeek(NSTimestamp value) {
        return new NSTimestamp(ERXTimestampUtility.yearOfCommonEra(value), ERXTimestampUtility.monthOfYear(value), -ERXTimestampUtility.dayOfWeek(value) + 1, 0, 0, 0, NSTimeZone.defaultTimeZone());
    }
View Full Code Here

    public static NSTimestamp firstDateInSameWeek(NSTimestamp value) {
        return new NSTimestamp(ERXTimestampUtility.yearOfCommonEra(value), ERXTimestampUtility.monthOfYear(value), -ERXTimestampUtility.dayOfWeek(value) + 1, 0, 0, 0, NSTimeZone.defaultTimeZone());
    }

    public static NSTimestamp firstDateInSameMonth(NSTimestamp value) {
        return new NSTimestamp(ERXTimestampUtility.yearOfCommonEra(value), ERXTimestampUtility.monthOfYear(value), -ERXTimestampUtility.dayOfMonth(value)+1, 0, 0, 0, NSTimeZone.defaultTimeZone());
    }
View Full Code Here

  private BigDecimal randomPrice() {
    return BigDecimal.valueOf((double) randomInt(10000) / (double) 100).setScale(2, BigDecimal.ROUND_DOWN);
  }

  private NSTimestamp randomTime() {
    return new NSTimestamp(randomInt((int) (System.currentTimeMillis() / 1000)) * 1000);
  }
 
View Full Code Here

public class Comment {
  private NSTimestamp _creationDate;
  private String _text;

  public Comment() {
    _creationDate = new NSTimestamp();
  }
View Full Code Here

TOP

Related Classes of com.webobjects.foundation.NSTimestamp

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.