Code example for Calendar

Methods: clone

0
     * 
     * @throws NullPointerException if <code>calendar</code> is 
     *     <code>null</code>. 
     */ 
    public long getFirstMillisecond(Calendar calendar) {
        Calendar c = (Calendar) calendar.clone();
        c.clear();
        c.set(Calendar.YEAR, this.year);
        c.set(Calendar.WEEK_OF_YEAR, this.week);
        c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek());
        c.set(Calendar.HOUR, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        //return c.getTimeInMillis();  // this won't work for JDK 1.3 
        return c.getTime().getTime();
    } 
 
    /** 
     * Returns the last millisecond of the week, evaluated using the supplied 
     * calendar (which determines the time zone).