Example usage for java.util Calendar clear

List of usage examples for java.util Calendar clear

Introduction

In this page you can find the example usage for java.util Calendar clear.

Prototype

public final void clear() 

Source Link

Document

Sets all the calendar field values and the time value (millisecond offset from the Epoch) of this Calendar undefined.

Usage

From source file:org.richfaces.component.CalendarComponentTest.java

public void testCalendarDecode() throws Exception {

    Calendar calendarObject = Calendar.getInstance();
    calendarObject.clear();
    calendarObject.set(2001, Calendar.SEPTEMBER, 11);
    calendar.decode(facesContext);/*  www .  j ava 2 s  .c  om*/
    //assertEquals(calendarObject.getTime(), calendar.getSubmittedValue());
    calendarObject.set(2002, Calendar.SEPTEMBER, 11, 1, 1, 1);
    calendar.updateCurrentDate(facesContext, calendarObject.getTime());
    assertEquals(calendarObject.getTime(), calendar.getCurrentDate());

}

From source file:org.photovault.imginfo.Test_PhotoQuery.java

@Test
public void testFuzzyDatePossible() {
    PhotoQuery q = new PhotoQuery();

    // First, check cases where the midpoint belongs to the fuzziness range
    Calendar cal = Calendar.getInstance();
    cal.clear();
    cal.set(2002, 11, 24);/*from  w w  w.  java 2  s  . com*/
    FuzzyDate fd1 = new FuzzyDate(cal.getTime(), 1.0);
    q.setFuzzyDateCriteria(PhotoQuery.FIELD_SHOOTING_TIME, PhotoQuery.FIELD_SHOOTING_TIME_ACCURACY, fd1,
            QueryFuzzyTimeCriteria.INCLUDE_POSSIBLE);
    // All expected to be included with INCLUDE_POSSIBLE
    boolean[] expected2 = { true, true, true, true };
    checkResults(q, expected2);
}

From source file:org.richfaces.component.CalendarComponentTest.java

public void testGetPreloadDateRange() throws Exception {
    UICalendar calendar = (UICalendar) application.createComponent(UICalendar.COMPONENT_TYPE);
    calendar.setLocale(Locale.FRENCH);
    Calendar calendarObject = Calendar.getInstance();
    calendarObject.clear();
    calendarObject.set(2007, Calendar.JUNE, 10);
    calendar.setCurrentDate(calendarObject.getTime());

    Date[] range = calendar.getPreloadDateRange();
    assertEquals(calendar.getPreloadDateRangeBegin(), range[0]);
    assertEquals(calendar.getPreloadDateRangeEnd(), range[range.length - 1]);
    assertEquals(30, range.length);//from   w w  w .  j  a v a 2  s .  c o m
}

From source file:com.zigabyte.stock.stratplot.StockMarketHistoryViewer.java

/** Refresh the stock list after the stock market history is changed. **/
private void refreshList() {
    if (this.stockMarketHistory != null && this.stockMarketHistory.size() > 0) {
        SortedSet<StockHistory> sortedStockHistories = new TreeSet<StockHistory>(TO_STRING_COMPARATOR);
        int index = 0;
        Calendar calendar = new GregorianCalendar();
        for (StockHistory stockHistory : stockMarketHistory) {
            if (stockHistory.size() > 0) {
                calendar.clear();
                calendar.setTime(stockHistory.get(0).getDate());
                sortedStockHistories.add(stockHistory);
            }/*from w ww . j a  v a  2s.c o  m*/
        }
        stockList.setListData(sortedStockHistories.toArray());
    } else {
        stockList.setListData(new Object[] {});
    }
}

From source file:org.photovault.imginfo.Test_PhotoQuery.java

@Test
public void testFuzzyDateCertain() {
    PhotoQuery q = new PhotoQuery();

    // First, check cases where the midpoint belongs to the fuzziness range
    Calendar cal = Calendar.getInstance();
    cal.clear();
    cal.set(2002, 11, 24);// w ww  . j  av a  2  s  .com
    FuzzyDate fd1 = new FuzzyDate(cal.getTime(), 1.0);
    q.setFuzzyDateCriteria(PhotoQuery.FIELD_SHOOTING_TIME, PhotoQuery.FIELD_SHOOTING_TIME_ACCURACY, fd1,
            QueryFuzzyTimeCriteria.INCLUDE_CERTAIN);
    // All expected to be included with INCLUDE_POSSIBLE
    boolean[] expected3 = { false, true, false, false };
    checkResults(q, expected3);

}

From source file:org.richfaces.component.CalendarComponentTest.java

public void testCalendarGetConvertedValue() throws Exception {
    UICalendar calendar = (UICalendar) application.createComponent(UICalendar.COMPONENT_TYPE);
    Calendar calendarObject = Calendar.getInstance();
    calendarObject.clear();
    calendarObject.set(2007, Calendar.JUNE, 10);
    calendar.setCurrentDate(calendarObject.getTime());
    calendar2.setDatePattern("dd/M/yy");
    calendar.getConvertedValue(facesContext, "01/01/01");
    calendar.getAsDate(new Date());
    calendar.getAsLocale("ru_RU");
    CalendarRendererBase renderer = new CalendarRenderer();

    renderer.getConvertedValue(facesContext, calendar, new Date());
}

From source file:org.photovault.imginfo.Test_PhotoQuery.java

@Test
public void testFuzzyDateProbable() {
    PhotoQuery q = new PhotoQuery();

    // First, check cases where the midpoint belongs to the fuzziness range
    Calendar cal = Calendar.getInstance();
    cal.clear();
    cal.set(2002, 11, 24);//w  w  w.ja va 2s .c o  m
    FuzzyDate fd1 = new FuzzyDate(cal.getTime(), 1.0);
    // First the case in which there is only lower bound
    q.setFuzzyDateCriteria(PhotoQuery.FIELD_SHOOTING_TIME, PhotoQuery.FIELD_SHOOTING_TIME_ACCURACY, fd1,
            QueryFuzzyTimeCriteria.INCLUDE_PROBABLE);
    // Image 2 should not be included since its fuzzy range is
    // larger that search range
    boolean[] expected1 = { true, true, false, true };
    checkResults(q, expected1);
}

From source file:org.photovault.imginfo.Test_PhotoQuery.java

/**
   This query checks that query can be modified and that the results are shown correctly
   Tjis is originally implemented to find demonstrate a defect in which the reuslt set was not cleaned
   before the new query./*from  w w  w  .  j  a v a 2 s.co m*/
*/
@Test
public void testQueryModification() {
    PhotoQuery q = new PhotoQuery();

    Calendar cal = Calendar.getInstance();
    cal.clear();
    cal.set(2002, 11, 24);
    // First the case in which there is only lower bound
    q.setFieldCriteriaRange(PhotoQuery.FIELD_SHOOTING_TIME, null, cal.getTime());
    boolean[] expected3 = { true, true, true, false };
    checkResults(q, expected3);
    // Then add the lower bound, part of the photos should not be in result set this time
    q.setFieldCriteriaRange(PhotoQuery.FIELD_SHOOTING_TIME, cal.getTime(), cal.getTime());
    boolean[] expected2 = { false, true, true, false };
    checkResults(q, expected2);
}

From source file:org.spring.data.gemfire.app.dao.provider.JdbcUserDao.java

protected Calendar convert(final Timestamp timestamp) {
    if (timestamp != null) {
        Calendar dateTime = Calendar.getInstance();
        dateTime.clear();
        dateTime.setTime(timestamp);/*from  www  . jav a 2 s. co  m*/
        return dateTime;
    }

    return null;
}

From source file:org.ovirt.api.metamodel.tests.JsonWriterTest.java

/**
 * Checks that dates are written correctly.
 *///from www .ja va 2 s.  c  o  m
@Test
public void testDate() {
    java.util.TimeZone tz = java.util.TimeZone.getTimeZone("UTC+1");
    Calendar calendar = Calendar.getInstance(tz);
    calendar.clear();
    calendar.set(2015, 12, 17, 16, 18, 23);
    calendar.set(Calendar.MILLISECOND, 123);
    Date date = calendar.getTime();
    V4Vm object = vm().creationTime(date).build();
    assertEquals("{'creation_time':'2016-01-17T16:18:23.123Z'}", objectToJson(object));
}