Package java.util

Examples of java.util.GregorianCalendar.roll()


  public void ageShouldBe33() {
    int expectedAge = 33;

    Calendar birth = new GregorianCalendar();
    birth.roll(Calendar.YEAR, expectedAge * (-1));
    birth.roll(Calendar.DAY_OF_YEAR, -1);

    Customer38 customer = new Customer38("Rita", "Navalhas", "rnavalhas@gmail.com", "+351 123 4565");
    customer.setDateOfBirth(birth.getTime());

    customer.calculateAge();
View Full Code Here


        StandardArticle art2 = article(2);
        StandardArticle art3 = article(3);

        // Set future date to the first article
        GregorianCalendar cal = new GregorianCalendar();
        cal.roll(Calendar.YEAR, 1);
        Date futureDate = cal.getTime();
        art1.setPublicationDate(futureDate);

        // Add the "future" article during the first update
        feed.updateArticles(new StandardArticle[] { art1 });
View Full Code Here

        StandardArticle art2 = article(2);
        StandardArticle art3 = article(3);

        // Set future date to the first article
        GregorianCalendar cal = new GregorianCalendar();
        cal.roll(Calendar.YEAR, 1);
        Date futureDate = cal.getTime();
        art1.setPublicationDate(futureDate);

        // Set the dates so that the art2 is newer than art3
        art2.setPublicationDate(new Date(3));
View Full Code Here

      }
 
      GregorianCalendar cal = new GregorianCalendar();
      cal.setTime(log_date);
      for (int i = 0; i < window; i++) {
        cal.roll(Calendar.DAY_OF_YEAR, false);
        Date temp = cal.getTime();
        String datestr = df.format(temp);
        if (tablenames.contains(domainsprefix + "_" + datestr)
            && tablenames.contains(resipsprefix + "_" + datestr)) {
          prevDates.add(temp);
View Full Code Here

        long estimatedMillis = (long) (millisPerFile * length) - elapsedMillis;
        //long estimatedMillis = (long) (millisPerFile * getFileNumber()) - elapsedMillis;

        GregorianCalendar estimatedCalendar = new GregorianCalendar();
        estimatedCalendar.setTimeInMillis(estimatedMillis);
        estimatedCalendar.roll(Calendar.HOUR, false);

        return estimatedCalendar;
    }

    /**
 
View Full Code Here

   */
  public void test_rollII() {
    // Test for method void java.util.GregorianCalendar.roll(int, int)
    GregorianCalendar gc = new GregorianCalendar(1972, Calendar.OCTOBER, 8,
        2, 5, 0);
    gc.roll(Calendar.DAY_OF_MONTH, -1);
    assertTrue("Failed to roll DAY_OF_MONTH down by 1", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 7, 2, 5,
            0)));
    gc = new GregorianCalendar(1972, Calendar.OCTOBER, 8, 2, 5, 0);
    gc.roll(Calendar.DAY_OF_MONTH, 25);
View Full Code Here

    gc.roll(Calendar.DAY_OF_MONTH, -1);
    assertTrue("Failed to roll DAY_OF_MONTH down by 1", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 7, 2, 5,
            0)));
    gc = new GregorianCalendar(1972, Calendar.OCTOBER, 8, 2, 5, 0);
    gc.roll(Calendar.DAY_OF_MONTH, 25);
    assertTrue("Failed to roll DAY_OF_MONTH up by 25", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 2, 2, 5,
            0)));
    gc = new GregorianCalendar(1972, Calendar.OCTOBER, 8, 2, 5, 0);
    gc.roll(Calendar.DAY_OF_MONTH, -10);
View Full Code Here

    gc.roll(Calendar.DAY_OF_MONTH, 25);
    assertTrue("Failed to roll DAY_OF_MONTH up by 25", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 2, 2, 5,
            0)));
    gc = new GregorianCalendar(1972, Calendar.OCTOBER, 8, 2, 5, 0);
    gc.roll(Calendar.DAY_OF_MONTH, -10);
    assertTrue("Failed to roll DAY_OF_MONTH down by 10", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 29, 2, 5,
            0)));
  }
View Full Code Here

   */
  public void test_rollIZ() {
    // Test for method void java.util.GregorianCalendar.roll(int, boolean)
    GregorianCalendar gc = new GregorianCalendar(1972, Calendar.OCTOBER,
        13, 19, 9, 59);
    gc.roll(Calendar.DAY_OF_MONTH, false);
    assertTrue("Failed to roll day_of_month down", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 12, 19,
            9, 59)));
    gc = new GregorianCalendar(1972, Calendar.OCTOBER, 13, 19, 9, 59);
    gc.roll(Calendar.DAY_OF_MONTH, true);
View Full Code Here

    gc.roll(Calendar.DAY_OF_MONTH, false);
    assertTrue("Failed to roll day_of_month down", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 12, 19,
            9, 59)));
    gc = new GregorianCalendar(1972, Calendar.OCTOBER, 13, 19, 9, 59);
    gc.roll(Calendar.DAY_OF_MONTH, true);
    assertTrue("Failed to roll day_of_month up", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 14, 19,
            9, 59)));
    gc = new GregorianCalendar(1972, Calendar.OCTOBER, 31, 19, 9, 59);
    gc.roll(Calendar.DAY_OF_MONTH, true);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.