java calendar

Posted on 2005-04-14
Last Modified: 2010-08-05
using the java.util.* package, I was trying to get all the days/date in the current week.
Some thing like:

Monday        April 11
Tuesday       April 12
Wednesday  April 13
Thrusday     April 14
Friday          April 15
Saturday      April 16
Sunday        April 17

And then the next week (if I have a next button) (7 days at a time)
Can somebody please help?

Question by:neokeet
    LVL 86

    Accepted Solution

               Calendar cal = Calendar.getInstance();
                cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
                for(int i = 0;i < 7;i++) {
                      cal.add(Calendar.DATE, 1);

    Increment the week number by 1 for the following week
    LVL 6

    Expert Comment

    If you need the dates in the format you listed, use a date formatter like this:

    DateFormat formatter = new SimpleDateFormat("EEEE MMMM dd");

    LVL 86

    Expert Comment


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now