Package java.util

Examples of java.util.Calendar


    private final Logger log = Logger.getLogger(getClass().getSimpleName());

    @Test
    public void testfromDateTime1() throws ParseException {
        //System.out.println(Helper.toDateTime(new Date()));
        Calendar cal = getExpectedCalendar();
        cal.set(Calendar.HOUR_OF_DAY, 11 + 4 + 2);
        // hour + 4h (because +f -04:00) + 2h (because of GMT)
        Date date = Helper.fromDateTime("2008-05-19T11:00:02-04:00");
        assertEquals(date, cal.getTime());
    }
View Full Code Here


        assertEquals(date, cal.getTime());
    }

    @Test
    public void testfromDateTime2() throws ParseException {
        Calendar cal = getExpectedCalendar();
        cal.set(Calendar.HOUR_OF_DAY, 11);

        Date date = Helper.fromDateTime("2008-05-19T09:00:02Z");
        assertEquals(date, cal.getTime());
    }
View Full Code Here

        assertEquals(date, cal.getTime());
    }

    @Test
    public void testfromDateTime3() throws ParseException {
        Calendar cal = getExpectedCalendar();
        cal.set(Calendar.HOUR_OF_DAY, 11);

        Date date = Helper.fromDateTime("2008-05-19T11:00:02+0200");
        assertEquals(date, cal.getTime());
    }
View Full Code Here

        assertEquals(date, cal.getTime());
    }

    @Test
    public void testfromDateTime4() throws ParseException {
        Calendar cal = getExpectedCalendar();
        cal.set(Calendar.HOUR_OF_DAY, 11);

        Date date = Helper.fromDateTime("2008-05-19T09:00:02");
        assertEquals(date, cal.getTime());
    }
View Full Code Here

                "firstelement");
    }

    @Test
    public void testToLocalDateTime() throws ParseException {
        Calendar cal = getExpectedCalendar();
        cal.set(Calendar.HOUR_OF_DAY, 11);

        assertEquals(Helper.toLocalDateTime(cal.getTime()),
                "2008-05-19T11:00:02");
    }
View Full Code Here

                "2008-05-19T11:00:02");
    }

    @Test
    public void testFromLocalDateTime() throws ParseException {
        Calendar cal = getExpectedCalendar();
        cal.set(Calendar.HOUR_OF_DAY, 11);

        // Methode sollte immer das Gleiche zurückliefern unabhängig vom offset.
        Date date = Helper.fromLocalDateTime("2008-05-19T11:00:02+0200");
        assertEquals(date, cal.getTime());

        date = Helper.fromLocalDateTime("2008-05-19T11:00:02-06:00");
        assertEquals(date, cal.getTime());

        date = Helper.fromLocalDateTime("2008-05-19T11:00:02");
        assertEquals(date, cal.getTime());
    }
View Full Code Here

        date = Helper.fromLocalDateTime("2008-05-19T11:00:02");
        assertEquals(date, cal.getTime());
    }

    private Calendar getExpectedCalendar() {
        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Europe/Berlin"));
        // Falls man dies haben will:  Calendar cal = Calendar.getInstance();
        // muss man dies aufrufen: cal.set(Calendar.HOUR, 11 - 4);

        cal.set(Calendar.YEAR, 2008);
        cal.set(Calendar.MONTH, 4);
        cal.set(Calendar.DAY_OF_MONTH, 19);
        // Die nächste Zeile wird beim Aufrufer überschrieben
        // cal.set(Calendar.HOUR, 11);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 2);
        cal.set(Calendar.MILLISECOND, 0);
        return cal;
    }
View Full Code Here

    mapper = getMapper("dateFormat.xml");
  }

  @Test
  public void testConversion() {
    Calendar calendar = Calendar.getInstance();
    calendar.set(2009, 6, 3, 12, 20, 10);
    DateContainer result = mapper.map(calendar.getTime(), DateContainer.class);
    assertNotNull(result);
    assertEquals("2009-07-03 12:20:10", result.getDate());
    assertEquals("2009-07-03 12:20:10", result.getSet().iterator().next());
  }
View Full Code Here

  @Test
  public void testConversion_Calendar() {
    GregorianCalendar cal = new GregorianCalendar(2009, 2, 3);
    Date sourceValue = cal.getTime();
    Calendar result = mapper.map(sourceValue, Calendar.class);
    assertEquals(cal.getTime(), result.getTime());
  }
View Full Code Here

        status = new StringMember("Status", (String)hm.get("Status"), mfrmx.getFieldRight(
            "Projects", "status"), "URL", 'T', false);

        if (hm.get("End") != null) {
          java.util.Date dt = (java.util.Date)hm.get("End");
          Calendar cal = Calendar.getInstance();
          cal.setTime(dt);
          cal.set(Calendar.HOUR, 12);
          cal.set(Calendar.MINUTE, 0);
          dueDate = new PureDateMember("DueDate", cal.getTime(), mfrmx.getFieldRight("Projects",
              "end"), "URL", 'T', false, 100, "EST");
        } else
          dueDate = new PureDateMember("DueDate", null, mfrmx.getFieldRight("Projects", "end"),
              "URL", 'T', false, 100, "EST");
View Full Code Here

TOP

Related Classes of java.util.Calendar

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.