This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch: java.util.Calendar




On 25 Apr 2001, Tom Tromey wrote:
> As it happens I'm doing work in this area right now as well.

Yeah, I saw your PR after I hit "Send"...

> If you could send me your Calendar test I'd be happy to make it into
> Mauve test and check it in.  Sooner is good for me...

Attached.

> I'll try to look at this in the near future (like tomorrow or Friday).
> I've been trying to make minimal changes to get the pieces of this I
> need working.  However it might not be possible to do that.
> Substantial work might be required :-(

Everything I need works with this patch.  Most likely there will still be
bugs though.  I wanted to write a more comprehensive test, but ran out
of time.

Jeff
import java.text.*;
import java.util.*;

public class DT {
    public static void main(String[] args) {
	try {
	    DateFormat format = new SimpleDateFormat("MM/dd/yyyy");
	    Calendar calendar = Calendar.getInstance();
	    Date date = format.parse("04/30/2001");

	    calendar.setTime(date);
	    // Should print "04/30/2001"
	    System.out.println(format.format(date));
	    // Should print "weekday = 2"
	    System.out.println("weekday = " +
		calendar.get(Calendar.DAY_OF_WEEK));

	    calendar.add(Calendar.DATE, 1);
	    date = calendar.getTime();
	    // Should print "05/01/2001"
	    System.out.println(format.format(date));
	    // Should print "weekday = 3"
	    System.out.println("weekday = " +
		calendar.get(Calendar.DAY_OF_WEEK));

	    calendar.add(Calendar.MONTH, 1);
	    date = calendar.getTime();
	    // Should print "06/01/2001"
	    System.out.println(format.format(date));
	    // Should print "weekday = 6"
	    System.out.println("weekday = " +
		calendar.get(Calendar.DAY_OF_WEEK));
	} catch (Throwable t) {
	    t.printStackTrace();
	}
    }
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]