3:39 am - Saturday August 19, 2017

Calendar in java example program getMaximum(int field)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

/*
@author:candidjava.com
@description:  Program that Returns the maximum value for the given calendar field of this Calendar instance.
*/
import java.util.Calendar;
public class CalendarMax {
void Max_Calendar() {
Calendar c = Calendar.getInstance(); // calendar creation
int max = c.getMaximum(Calendar.DAY_OF_WEEK);
System.out.println("Max Days:" + max);
max = c.getMaximum(Calendar.MONTH);
System.out.println("Max months:" + max);
max = c.getMaximum(Calendar.YEAR);
System.out.println("Max years:" + max);
}
public static void main(String args[]) {
CalendarMax cm = new CalendarMax();
cm.Max_Calendar();
}
}

//output:
Max Days:7
Max months:11
Max years:292278994

BACK

Filed in: Z-A All Java Codes

Comments are closed.