Code example for Calendar

Methods: getTime, set

0
     * 
     * @throws NullPointerException if <code>calendar</code> is 
     *     <code>null</code>. 
     */ 
    public long getFirstMillisecond(Calendar calendar) {
        calendar.set(this.year, this.month - 1, 1, 0, 0, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        // in the following line, we'd rather call calendar.getTimeInMillis() 
        // to avoid object creation, but that isn't supported in Java 1.3.1 
        return calendar.getTime().getTime();
    } 
 
    /** 
     * Returns the last millisecond of the month, evaluated using the supplied 
     * calendar (which determines the time zone). 
     * 
     * @param calendar  the calendar (<code>null</code> not permitted). 
     * 
     * @return The last millisecond of the month. 
     * 
     * @throws NullPointerException if <code>calendar</code> is 
     *     <code>null</code>. 
     */ 
    public long getLastMillisecond(Calendar calendar) {
        int eom = SerialDate.lastDayOfMonth(this.month, this.year);
        calendar.set(this.year, this.month - 1, eom, 23, 59, 59);
        calendar.set(Calendar.MILLISECOND, 999);
        // in the following line, we'd rather call calendar.getTimeInMillis() 
        // to avoid object creation, but that isn't supported in Java 1.3.1 
        return calendar.getTime().getTime();
    } 
 
    /** 
     * Parses the string argument as a month.  This method is required to 
     * accept the format "YYYY-MM".  It will also accept "MM-YYYY". Anything