예제 #1
0
 public void testBadField() throws ParseException {
   DatePicker p = makePicker(Locale.ENGLISH);
   Date d = parseDate("1996-08-03T15:33");
   p.setDate(d);
   p.setMonth(new Integer(13));
   assertNull(p.getYear());
 }
예제 #2
0
  public void testDateFormat() {
    DatePicker p = makePicker(Locale.ENGLISH);
    assertTrue(p.isLatin());
    assertTrue(!p.isDayBeforeMonth());

    p = makePicker(Locale.GERMAN);
    assertTrue(!p.isLatin());
    assertTrue(p.isDayBeforeMonth());
  }
예제 #3
0
  public void testReadWriteFromMap() throws ParseException {
    HashMap form = new HashMap();
    DatePicker p = makePicker(Locale.ENGLISH);
    Date d = parseDate("1996-08-03T15:33");
    p.setDate(d);
    p.writeToMap(form);

    p = makePicker(Locale.ENGLISH);
    p.readMap(form);
    assertEquals(d, p.getDate());
  }
예제 #4
0
 public void testPositiveRange() throws ParseException {
   DatePicker p = makePicker(Locale.ENGLISH, DatePicker.YEAR_RANGE_POSITIVE);
   Date d = parseDate("2005-08-03T15:33");
   p.setDate(d);
   // the range is always the current year plus 4 (according to the test)
   // this test failed when hard coded with 2005 as year range 0.
   int curYear = Calendar.getInstance().get(Calendar.YEAR);
   assertEquals(2005, p.getYear());
   assertEquals(curYear, p.getYearRange()[0]);
   assertEquals(curYear + 4, p.getYearRange()[4]);
 }
예제 #5
0
 public void testSetDate() throws ParseException {
   DatePicker p = makePicker(Locale.ENGLISH);
   Date d = parseDate("1996-08-03T15:33");
   p.setDate(d);
   assertEquals(1996, p.getYear());
   assertEquals(7, p.getMonth()); // Months are zero-based !
   assertEquals(3, p.getDay());
   assertEquals(Calendar.PM, p.getAmPm());
   assertEquals(3, p.getHour());
   assertEquals(33, p.getMinute());
 }