How to Get the Start Date of the Week in Java

import java.text.DateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
  /*
 * Created on Feb 20, 2006
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
  /**
 * @author pu00125
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class Cal {
 public static void main(String ss[]){

  GregorianCalendar calendar = new GregorianCalendar();
  String[] months = new String[] { "NOV", "DEC", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT" };

  for(int i=0;i<12;i++){

   calendar.set(2006,i,1);
   System.out.println("startDay of Month " + calendar.get(Calendar.DAY_OF_WEEK));
   System.out.println("max Days: " + calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
 }
 

  java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyyMMdd");
  //String date = formatter.format(GregorianCalendar.getTime());
 // return formattedDate.toUpperCase();
 

  /*System.out.println("DAY_OF_WEEK_IN_MONTH: "+ calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH));
   System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR));
   System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK));
   System.out.println("MONTH: " + calendar.get(GregorianCalendar.MONTH));*/
   System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH));
   //System.out.println("First Day: " + calendar.getLeastMaximum()calendar.getFirstDayOfWeek());

   }
}

Java Tips by : Sankar Reddy

Quick Links:
Have Java Problem
Do you have a Java Question?

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Best Regards,
Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.