@TestTargetNew(
      level = TestLevel.COMPLETE,
      notes = "",
      method = "roll",
      args = {int.class, int.class})
  public void test_rollII() {
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+2"), defaultLocale);

    cal.setTimeInMillis(1222185600225L);
    cal.roll(Calendar.DAY_OF_MONTH, 200);
    assertEquals(cal.get(Calendar.ERA), 1);
    assertEquals(cal.get(Calendar.YEAR), 2008);
    assertEquals(cal.get(Calendar.MONTH), Calendar.SEPTEMBER);
    assertEquals(cal.get(Calendar.DAY_OF_MONTH), 13);
    // Following line returns wrong value. Behavior uncompatible with RI.
    assertEquals(cal.get(Calendar.HOUR_OF_DAY), 18);
    assertEquals(cal.get(Calendar.MINUTE), 0);
    cal.roll(Calendar.DAY_OF_MONTH, -200);
    assertEquals(cal.get(Calendar.ERA), 1);
    assertEquals(cal.get(Calendar.YEAR), 2008);
    assertEquals(cal.get(Calendar.MONTH), Calendar.SEPTEMBER);
    assertEquals(cal.get(Calendar.DAY_OF_MONTH), 23);
    assertEquals(cal.get(Calendar.HOUR_OF_DAY), 18);
    assertEquals(cal.get(Calendar.MINUTE), 0);
  }
Exemplo n.º 2
0
	void reset() {
		Log.d(TAG, "reset EMABudgeter");
		
		resetMinTimes();
		resetBudgets();
		
		// reset the budgets at 4am
		Calendar cal = Calendar.getInstance();

		cal.set(Calendar.MINUTE, 0);
		cal.set(Calendar.SECOND, 0);
		cal.set(Calendar.MILLISECOND, 0);
		
		int hour=0;
		do {
    		cal.roll(Calendar.HOUR_OF_DAY, true);
    		hour = cal.get(Calendar.HOUR_OF_DAY);
    		if (hour == 0) {
    			cal.roll(Calendar.DAY_OF_YEAR, true);
    		}    		
		} while (hour != EMABudgeter.RESET_BUDGET_HOUR);

		
		timeToReset = cal.getTimeInMillis();
				
		String s = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(cal.getTime());
		Log.d(TAG, "timeToReset = " + s);
	}
Exemplo n.º 3
0
 /**
  * Retorna o valor do hor�rio maximo para a data de referencia passada. <br>
  * <br>
  * Por exemplo se a data for "30/01/2009 as 17h:33m:12s e 299ms" a data retornada por este metodo
  * ser� "30/01/2009 as 23h:59m:59s e 999ms".
  *
  * @param date de referencia.
  * @return {@link Date} que representa o hor�rio maximo para dia informado.
  */
 public static Date highDateTime(Date date) {
   Calendar aux = Calendar.getInstance();
   aux.setTime(date);
   toOnlyDate(aux); // zera os parametros de hour,min,sec,milisec
   aux.roll(Calendar.DATE, true); // vai para o dia seguinte
   aux.roll(Calendar.MILLISECOND, false); // reduz 1 milisegundo
   return aux.getTime();
 }
Exemplo n.º 4
0
  @Test
  public void test() throws Exception {
    String xml =
        Files.forIO().readFrom(getClass().getResourceAsStream("metricReport.xml"), "utf-8");

    MetricReport metricReport = DefaultSaxParser.parse(xml);

    MetricReportForABTestVisitor visitor = new MetricReportForABTestVisitor();

    metricReport.accept(visitor);

    Map<Integer, AbtestReport> result = visitor.getReportMap();

    Calendar calendar = Calendar.getInstance();
    Date now = new Date();
    calendar.setTime(now);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.roll(Calendar.DAY_OF_MONTH, -14);

    for (AbtestReport ar : result.values()) {
      if (ar.getRunId() != -1) {
        System.out.println(ar.toString());
        for (int i = 0; i < 14; i++) {
          for (int j = 0; j < 24; j++) {
            Date begin = calendar.getTime();

            calendar.roll(Calendar.HOUR_OF_DAY, true);
            Date end = calendar.getTime();

            System.out.println("Import new report for " + begin);
            ar.setStartTime(begin);
            ar.setEndTime(end);

            com.dianping.cat.home.dal.abtest.AbtestReport report =
                new com.dianping.cat.home.dal.abtest.AbtestReport();
            report.setPeriod(begin);
            report.setRunId(ar.getRunId());
            report.setContent(ar.toString());

            m_abtestReportDao.insert(report);
          }
          calendar.roll(Calendar.DAY_OF_MONTH, true);
        }
      }
    }
  }
Exemplo n.º 5
0
  @Override
  public Cursor loadInBackground() {
    final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    // generate a time limit (24 hours)
    Calendar cal = Calendar.getInstance();
    cal.roll(Calendar.DATE, -1);
    String timestamp_limit = formatter.format(cal.getTime());

    try {
      // limit to specific download
      return getContext()
          .getContentResolver()
          .query(
              StatsContentProvider.STATS_URI,
              StatsEntry.PROJECTION,
              StatsEntry.TIMESTAMP + " >= ?",
              new String[] {timestamp_limit},
              StatsEntry.TIMESTAMP + " ASC");
    } catch (Exception e) {
      Log.e(TAG, "loadInBackground() failed", e);
    }

    return null;
  }
Exemplo n.º 6
0
 // 获得本年有多少天
 private int getMaxYear() {
   Calendar cd = Calendar.getInstance();
   cd.set(Calendar.DAY_OF_YEAR, 1); // 把日期设为当年第一天
   cd.roll(Calendar.DAY_OF_YEAR, -1); // 把日期回滚一天。
   int MaxYear = cd.get(Calendar.DAY_OF_YEAR);
   return MaxYear;
 }
Exemplo n.º 7
0
 // 计算一个月的最后一天
 public Date lastDayOfMonth(Date date) {
   Calendar cal = Calendar.getInstance();
   cal.setTime(date);
   cal.set(Calendar.DAY_OF_MONTH, 1);
   cal.roll(Calendar.DAY_OF_MONTH, -1);
   return cal.getTime();
 }
Exemplo n.º 8
0
  public static TimeInfo getLastMonthStartAndEndTime() {
    Calendar calendar1 = Calendar.getInstance();
    calendar1.add(Calendar.MONTH, -1);
    calendar1.set(Calendar.DATE, 1);
    calendar1.set(Calendar.HOUR_OF_DAY, 0);
    calendar1.set(Calendar.MINUTE, 0);
    calendar1.set(Calendar.SECOND, 0);
    calendar1.set(Calendar.MILLISECOND, 0);
    Date startDate = calendar1.getTime();
    long startTime = startDate.getTime();

    Calendar calendar2 = Calendar.getInstance();
    calendar2.add(Calendar.MONTH, -1);
    calendar2.set(Calendar.DATE, 1);
    calendar2.set(Calendar.HOUR_OF_DAY, 23);
    calendar2.set(Calendar.MINUTE, 59);
    calendar2.set(Calendar.SECOND, 59);
    calendar2.set(Calendar.MILLISECOND, 999);
    calendar2.roll(Calendar.DATE, -1);
    Date endDate = calendar2.getTime();
    long endTime = endDate.getTime();
    TimeInfo info = new TimeInfo();
    info.setStartTime(startTime);
    info.setEndTime(endTime);
    return info;
  }
Exemplo n.º 9
0
    @Override
    public View getItem(int index, View cachedView, ViewGroup parent) {
      int day = /*-daysCount/2 + */ index;
      Calendar newCalendar = (Calendar) calendar.clone();
      newCalendar.roll(Calendar.DAY_OF_YEAR, day);

      TextView monthday = (TextView) super.getItem(index, cachedView, parent);
      //            TextView weekday = (TextView) view.findViewById(R.id.time2_weekday);
      //            if (day == 0) {
      //                weekday.setText(EMPTY);
      //            } else {
      //                weekday.setText(format_EEE.format(newCalendar.getTime()));
      //            }

      //            TextView monthday = (TextView) view.findViewById(R.id.time2_monthday);
      if (day == 0) {
        monthday.setText(TODAY);
        monthday.setTextColor(0xFF0000F0);
      } else {
        monthday.setText(df_MMM_d.format(newCalendar.getTime()));
        monthday.setTextColor(0xFF111111);
      }

      return monthday;
    }
Exemplo n.º 10
0
  public void execute(
      Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
      throws TemplateException, IOException {

    // 获取参数
    // 站点id
    String siteid = getParam(params, "siteid");
    // 类型
    String type = getParam(params, "type");

    if (body != null) {
      // 设置循环变量
      if (loopVars != null && loopVars.length > 0) {

        java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd");
        java.util.Calendar calendar = java.util.Calendar.getInstance();
        String today = df.format(calendar.getTime());
        calendar.roll(java.util.Calendar.DAY_OF_YEAR, -1);
        String yesterday = df.format(calendar.getTime());
        calendar.roll(java.util.Calendar.DAY_OF_YEAR, 1);
        if (calendar.get(java.util.Calendar.MONTH) == 0) {
          calendar.roll(java.util.Calendar.YEAR, -1);
        }
        calendar.roll(java.util.Calendar.MONTH, -1);
        String month = df.format(calendar.getTime());

        Visit visit = new Visit();
        visit.setSiteid(siteid);
        if ("today".equals(type)) {
          // 今天
          visit.setStarttime(DateUtil.parse(today, "yyyy-MM-dd"));
        } else if ("yesterday".equals(type)) {
          // 昨天
          visit.setStarttime(DateUtil.parse(yesterday, "yyyy-MM-dd"));
          visit.setEndtime(DateUtil.parse(today, "yyyy-MM-dd"));
        } else if ("month".equals(type)) {
          // 本月
          visit.setStarttime(DateUtil.parse(month, "yyyy-MM-dd"));
        }

        loopVars[0] =
            new SimpleNumber(
                visitService.count(visit, "true".equals(getParam(params, "cache")) ? true : false));
        body.render(env.getOut());
      }
    }
  }
Exemplo n.º 11
0
 public static void setCacheExpireDate(HttpServletResponse response, int seconds) {
   if (response != null) {
     Calendar cal = new GregorianCalendar();
     cal.roll(Calendar.SECOND, seconds);
     response.setHeader("Cache-Control", "PRIVATE, max-age=" + seconds + ", must-revalidate");
     response.setHeader("Expires", htmlExpiresDateFormat().format(cal.getTime()));
   }
 }
Exemplo n.º 12
0
 /**
  * 获取当前月的最后一天
  *
  * @return
  */
 public static String getCurMonthLastDay() {
   Calendar currentDate = java.util.Calendar.getInstance();
   currentDate.set(Calendar.DATE, 1);
   currentDate.roll(Calendar.DATE, -1);
   currentDate.set(Calendar.HOUR_OF_DAY, 23);
   currentDate.set(Calendar.MINUTE, 59);
   currentDate.set(Calendar.SECOND, 59);
   return dateToDateString((Date) currentDate.getTime().clone());
 }
 public void testExpiredCardFromLastMonth() {
   Calendar calendar = Calendar.getInstance();
   calendar.roll(Calendar.MONTH, -1);
   int year = calendar.get(Calendar.YEAR) % 100;
   int month = calendar.get(Calendar.MONTH) + 1;
   Card card = createValidCard("4111111111111111", "000");
   card.setExpYear(year);
   card.setExpMonth(month);
   assertFalse(card.isValid());
 }
Exemplo n.º 14
0
  /** @return */
  public String getNextMonthEnd() {
    String str = "";
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    Calendar lastDate = Calendar.getInstance();
    lastDate.add(Calendar.MONTH, 1); // 加一个月
    lastDate.set(Calendar.DATE, 1); // 把日期设置为当月第一天
    lastDate.roll(Calendar.DATE, -1); // 日期回滚一天,也就是本月最后一天
    str = sdf.format(lastDate.getTime());
    return str;
  }
Exemplo n.º 15
0
  /** @return */
  public String getNextYearEnd() {
    String str = "";
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    Calendar lastDate = Calendar.getInstance();
    lastDate.add(Calendar.YEAR, 1); // 加一个年
    lastDate.set(Calendar.DAY_OF_YEAR, 1);
    lastDate.roll(Calendar.DAY_OF_YEAR, -1);
    str = sdf.format(lastDate.getTime());
    return str;
  }
Exemplo n.º 16
0
  public static Date roll(Date date, int field, int amount) {
    Date newDate;
    Calendar calendar;

    calendar = Calendar.getInstance();
    calendar.setTime(date);
    calendar.roll(field, amount);

    newDate = calendar.getTime();

    return newDate;
  }
Exemplo n.º 17
0
 private int getMonthPlus() {
   Calendar cd = Calendar.getInstance();
   int monthOfNumber = cd.get(Calendar.DAY_OF_MONTH);
   cd.set(Calendar.DATE, 1); // 把日期设置为当月第一天
   cd.roll(Calendar.DATE, -1); // 日期回滚一天,也就是最后一天
   MaxDate = cd.get(Calendar.DATE);
   if (monthOfNumber == 1) {
     return -MaxDate;
   } else {
     return 1 - monthOfNumber;
   }
 }
Exemplo n.º 18
0
 private int getYearPlus() {
   Calendar cd = Calendar.getInstance();
   int yearOfNumber = cd.get(Calendar.DAY_OF_YEAR); // 获得当天是一年中的第几天
   cd.set(Calendar.DAY_OF_YEAR, 1); // 把日期设为当年第一天
   cd.roll(Calendar.DAY_OF_YEAR, -1); // 把日期回滚一天。
   int MaxYear = cd.get(Calendar.DAY_OF_YEAR);
   if (yearOfNumber == 1) {
     return -MaxYear;
   } else {
     return 1 - yearOfNumber;
   }
 }
 public static Object[] getAvailableGroups() {
   if (_groups == null) {
     Calendar cal = Calendar.getInstance();
     cal.set(Calendar.DAY_OF_WEEK_IN_MONTH, 0);
     _groups = new Object[cal.getMaximum(Calendar.DAY_OF_WEEK_IN_MONTH)];
     for (int i = 0; i < _groups.length; i++) {
       _groups[i] = getCalendarField(cal, Calendar.DAY_OF_WEEK_IN_MONTH);
       cal.roll(Calendar.DAY_OF_WEEK_IN_MONTH, 1);
     }
   }
   return _groups;
 }
Exemplo n.º 20
0
 /**
  * <br>
  * <b>功能:</b>一个月最大day<br>
  * <b>作者:</b>肖财高<br>
  * <b>日期:</b> 2013-4-9 <br>
  *
  * @param time 时间
  * @return obj[0]=maxMonth; obj[1]=time;
  */
 public Object[] getMaxMonth(String time) {
   Object[] obj = new Object[2];
   Date date = null;
   try {
     date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time);
   } catch (ParseException e) {
     e.printStackTrace();
   }
   Calendar a = Calendar.getInstance();
   a.setTime(date);
   a.set(Calendar.DATE, 1); // 把日期设置为当月第一天
   a.roll(Calendar.DATE, -1); // 日期回滚一天,也就是最后一天
   int maxMonth = a.get(Calendar.DATE);
   a.roll(Calendar.DATE, 1);
   // System.out.println("该月最大天数:"+maxMonth+",某月="+a.get(Calendar.MONTH));
   time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(a.getTime());
   // System.out.println("time="+time);
   obj[0] = maxMonth;
   obj[1] = time;
   return obj;
 }
Exemplo n.º 21
0
 // Single Booking
 public Calendar calculateStartCalendar(int bookingWeek, int bookingDay, int startTime) {
   System.out.println("param:" + bookingWeek + " " + bookingDay + " " + startTime);
   Calendar startCal = (Calendar) calendarReferencePoint.clone();
   startCal.roll(Calendar.WEEK_OF_YEAR, bookingWeek - 1);
   startCal.set(Calendar.DAY_OF_WEEK, bookingDay);
   startCal.set(Calendar.HOUR_OF_DAY, startTime / 100);
   startCal.set(Calendar.MINUTE, startTime % 100);
   System.out.println("Before Affirm:" + startCal.getTime());
   startCal = affirmSeconds(startCal);
   System.out.println("Begin:" + startCal.getTime());
   return startCal;
 }
Exemplo n.º 22
0
  @Deployment(
      resources = {
        "org/activiti/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml"
      })
  public void testTaskDueDate() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    Task task =
        taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();

    // Set due-date on task
    Date dueDate = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").parse("01/02/2003 01:12:13");
    task.setDueDate(dueDate);
    taskService.saveTask(task);

    assertEquals(
        1,
        taskService
            .createTaskQuery()
            .processInstanceId(processInstance.getId())
            .dueDate(dueDate)
            .count());

    Calendar otherDate = Calendar.getInstance();
    otherDate.add(Calendar.YEAR, 1);
    assertEquals(
        0,
        taskService
            .createTaskQuery()
            .processInstanceId(processInstance.getId())
            .dueDate(otherDate.getTime())
            .count());

    Calendar priorDate = Calendar.getInstance();
    priorDate.setTime(dueDate);
    priorDate.roll(Calendar.YEAR, -1);

    assertEquals(
        1,
        taskService
            .createTaskQuery()
            .processInstanceId(processInstance.getId())
            .dueAfter(priorDate.getTime())
            .count());

    assertEquals(
        1,
        taskService
            .createTaskQuery()
            .processInstanceId(processInstance.getId())
            .dueBefore(otherDate.getTime())
            .count());
  }
Exemplo n.º 23
0
  /**
   * @param 取指定年,月,日的下一日的开始时间,小时,分,秒为00:00:00
   * @param 主要是用来取跨月份的日期
   * @return
   */
  public Date getNextDayStart(int year, int month, int date) {
    month = month - 1;
    boolean lastDayOfMonth = false;
    boolean lastDayOfYear = false;

    Calendar time = Calendar.getInstance();
    time.set(year, month, date, 0, 0, 0);
    Calendar nextMonthFirstDay = Calendar.getInstance();
    nextMonthFirstDay.set(year, month + 1, 1, 0, 0, 0);

    if (time.get(Calendar.DAY_OF_YEAR) + 1 == nextMonthFirstDay.get(Calendar.DAY_OF_YEAR))
      lastDayOfMonth = true;

    if (time.get(Calendar.DAY_OF_YEAR) == time.getMaximum(Calendar.DATE)) lastDayOfYear = true;

    time.roll(Calendar.DATE, 1);

    if (lastDayOfMonth) time.roll(Calendar.MONTH, 1);

    if (lastDayOfYear) time.roll(Calendar.YEAR, 1);

    return time.getTime();
  }
  /**
   * Calculates the start and end date members from the given time information.
   *
   * <p>
   */
  private void calculateEntryDates() {

    // create the start date
    m_startDate = new GregorianCalendar();
    m_startDate.setTimeInMillis(m_startDay);
    m_startDate.set(Calendar.HOUR_OF_DAY, m_startTime.get(Calendar.HOUR_OF_DAY));
    m_startDate.set(Calendar.MINUTE, m_startTime.get(Calendar.MINUTE));
    // create the end date
    m_endDate = new GregorianCalendar();
    m_endDate.setTimeInMillis(m_startDay);
    m_endDate.set(Calendar.HOUR_OF_DAY, m_endTime.get(Calendar.HOUR_OF_DAY));
    m_endDate.set(Calendar.MINUTE, m_endTime.get(Calendar.MINUTE));
    m_endDate.roll(Calendar.DAY_OF_MONTH, m_duration);
  }
Exemplo n.º 25
0
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.date);
   EditText startDate = (EditText) findViewById(R.id.start_date);
   DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
   Date d = new Date();
   Calendar c = Calendar.getInstance();
   c.setTime(d);
   c.roll(Calendar.YEAR, -1);
   startDate.setText(df.format(c.getTime()));
   EditText endDate = (EditText) findViewById(R.id.end_date);
   endDate.setText(df.format(d));
 }
 /** @see ShortPatientFormValidator#validate(Object,Errors) */
 @Test
 @Verifies(
     value = "should fail validation if birthdate makes patient 120 years old or older",
     method = "validate(Object,Errors)")
 public void validate_shouldFailValidationIfBirthdateMakesPatient120YearsOldOrOlder()
     throws Exception {
   Patient p = ps.getPatient(2);
   Calendar c = Calendar.getInstance();
   c.roll(Calendar.YEAR, -121);
   p.setBirthdate(c.getTime());
   ShortPatientModel model = new ShortPatientModel(p);
   Errors errors = new BindException(model, "patientModel");
   validator.validate(model, errors);
   Assert.assertEquals(true, errors.hasFieldErrors());
 }
 private String adjustExpectedDataVolumePerDay(FileSystemMgt2 fsMgt, FileSystemDTO[] fss)
     throws Exception {
   Calendar cal = Calendar.getInstance();
   cal.roll(Calendar.DAY_OF_MONTH, false);
   long after = cal.getTimeInMillis();
   long sum = 0L;
   for (FileSystemDTO fs : fss) {
     sum += fsMgt.sizeOfFilesCreatedAfter(fs.getPk(), after);
   }
   String size = FileUtils.formatSize(sum);
   if (sum > expectedDataVolumePerDay) {
     server.setAttribute(super.serviceName, new Attribute("ExpectedDataVolumePerDay", size));
   }
   return size;
 }
Exemplo n.º 28
0
 /**
  * Applies BYMONTH rules specified in this Recur instance to the specified date list. If no
  * BYMONTH rules are specified the date list is returned unmodified.
  *
  * @param dates
  * @return
  */
 private DateList getMonthVariants(final DateList dates) {
   if (getMonthList().isEmpty()) {
     return dates;
   }
   final DateList monthlyDates = getDateListInstance(dates);
   for (final Date date : dates) {
     final Calendar cal = Dates.getCalendarInstance(date);
     cal.setTime(date);
     for (final Integer month : getMonthList()) {
       // Java months are zero-based..
       //                cal.set(Calendar.MONTH, month.intValue() - 1);
       cal.roll(Calendar.MONTH, (month.intValue() - 1) - cal.get(Calendar.MONTH));
       monthlyDates.add(Dates.getInstance(cal.getTime(), monthlyDates.getType()));
     }
   }
   return monthlyDates;
 }
Exemplo n.º 29
0
  /** {@inheritDoc} */
  public void executeTest(
      final Map<String, String> arguments, final IElementContext context, final Selenium selenium)
      throws Exception {

    // Retrieve the parameters.
    final String _locator = getArgTarget();
    final String _format = getArgFormat();
    final Integer _deviation = getArgDeviation();

    // Process the deviation
    Calendar calendar = Calendar.getInstance();
    calendar.roll(Calendar.DAY_OF_YEAR, _deviation);

    // Create the formatted date.
    final String _formattedDate = new SimpleDateFormat(_format).format(calendar.getTime());

    selenium.type(_locator, _formattedDate);
  }
Exemplo n.º 30
0
  public void /*test*/ UserWithItems() throws Exception {
    System.out.println("******************** testUserWithItems ********************");

    UserDAO userDAO = new UserDAO();
    assertTrue(userDAO.findAll().size() > 0);

    User user = new User();
    user.setFirstname("Christian");
    user.setAdmin(true);
    user.clearCreatedDate();

    Collection users = userDAO.findByExample(user);

    assertNotNull(users);
    Object[] userArr = users.toArray();
    assertTrue(userArr.length > 0);
    assertTrue(userArr[0] instanceof User);

    User christian = (User) userArr[0];
    assertNotNull(christian.getId());

    Set items = christian.getItems();
    Item item = (Item) items.toArray()[0];
    assertNotNull(item.getId());

    Calendar inThreeDays = GregorianCalendar.getInstance();
    inThreeDays.roll(Calendar.DAY_OF_YEAR, 3);
    Item newItem =
        new Item(
            "Item One",
            "An item in the carsLuxury category.",
            christian,
            new MonetaryAmount(new BigDecimal("1.99"), Currency.getInstance(Locale.US)),
            new MonetaryAmount(new BigDecimal("50.33"), Currency.getInstance(Locale.US)),
            new Date(),
            inThreeDays.getTime());

    christian.addItem(newItem);

    ItemDAO itemDAO = new ItemDAO();
    itemDAO.makePersistent(newItem);

    HibernateUtil.commitTransaction();
  }