Example usage for java.util Calendar SEPTEMBER

List of usage examples for java.util Calendar SEPTEMBER

Introduction

In this page you can find the example usage for java.util Calendar SEPTEMBER.

Prototype

int SEPTEMBER

To view the source code for java.util Calendar SEPTEMBER.

Click Source Link

Document

Value of the #MONTH field indicating the ninth month of the year in the Gregorian and Julian calendars.

Usage

From source file:Main.java

public static void main(String[] args) {
    GregorianCalendar gc = new GregorianCalendar(2010, Calendar.SEPTEMBER, 9);
    Date birthDate = gc.getTime();

    String pattern = "'I was born on the day' dd 'of the month 'MMMM 'in' yyyy";

    SimpleDateFormat simpleFormatter = new SimpleDateFormat(pattern);
    System.out.println(simpleFormatter.format(birthDate));
}

From source file:Main.java

public static void main(String[] args) {

    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:00Z");
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.YEAR, 2015);
    cal.set(Calendar.MONTH, Calendar.SEPTEMBER);
    cal.set(Calendar.DATE, 1);//from w w w.ja va  2s.c  om
    cal.set(Calendar.HOUR_OF_DAY, 12);
    cal.set(Calendar.MINUTE, 15);
    Date date = cal.getTime();
    System.out.println(date);
    TimeZone tz = TimeZone.getTimeZone("IST");
    dateFormat.setTimeZone(tz);
    String actual = dateFormat.format(date);

    System.out.println(actual);
}

From source file:Main.java

public static void main(String[] args) {
    Calendar now = Calendar.getInstance();
    System.out.println(now.getTime());
    int month = now.get(Calendar.MONTH);
    if (month == Calendar.JANUARY) {
        System.out.println("JANUARY");
    }//from ww  w.  j a v  a 2 s. c o m
    if (month == Calendar.FEBRUARY) {
        System.out.println("FEBRUARY");
    }
    if (month == Calendar.MARCH) {
        System.out.println("MARCH");
    }
    if (month == Calendar.APRIL) {
        System.out.println("APRIL");
    }
    if (month == Calendar.MAY) {
        System.out.println("MAY");
    }
    if (month == Calendar.JUNE) {
        System.out.println("JUNE");
    }
    if (month == Calendar.JULY) {
        System.out.println("JULY");
    }
    if (month == Calendar.AUGUST) {
        System.out.println("AUGUST");
    }
    if (month == Calendar.SEPTEMBER) {
        System.out.println("SEPTEMBER");
    }
    if (month == Calendar.OCTOBER) {
        System.out.println("OCTOBER");
    }
    if (month == Calendar.NOVEMBER) {
        System.out.println("NOVEMBER");
    }
    if (month == Calendar.DECEMBER) {
        System.out.println("DECEMBER");
    }

}

From source file:Main.java

public static String getActualSemesterTag() {
    final int month = GregorianCalendar.getInstance().get(Calendar.MONTH);
    if (month > Calendar.FEBRUARY && month < Calendar.SEPTEMBER)
        return "S";
    return "W";
}

From source file:Main.java

/**
 * @param days/*from  w w w.  ja v  a2s.c  o m*/
 *            number of days after September 02, 1975 (what happened on this
 *            day?)
 * @return
 */
public static Calendar getDayFromQuickLogEntry(int days) {
    Calendar logDay = GregorianCalendar.getInstance();
    logDay.set(Calendar.DAY_OF_MONTH, 2);
    logDay.set(Calendar.MONTH, Calendar.SEPTEMBER);
    logDay.set(Calendar.YEAR, 1975);
    logDay.add(Calendar.DAY_OF_YEAR, days);
    return logDay;
}

From source file:Main.java

public static Calendar getDateAwareCalendar() {
    Calendar calendar = new GregorianCalendar();

    // Check if the 1st of September is in two weeks. If so we need to download full timetable
    // for two weeks beginning from the 1st of September in advance.
    if (calendar.get(Calendar.MONTH) == Calendar.AUGUST && calendar.get(Calendar.DATE) >= 18) {
        calendar.set(Calendar.MONTH, Calendar.SEPTEMBER);
        calendar.set(Calendar.DATE, 1);
    }//from   w w  w . j a  v a 2s .c om

    prepareCalendarNoSunday(calendar);
    return calendar;
}

From source file:Main.java

public static String getMonthString(int month) {
    switch (month) {
    case Calendar.JANUARY:
        return "Jan";
    case Calendar.FEBRUARY:
        return "Feb";
    case Calendar.MARCH:
        return "Mar";
    case Calendar.APRIL:
        return "Apr";
    case Calendar.MAY:
        return "May";
    case Calendar.JUNE:
        return "Jun";
    case Calendar.JULY:
        return "Jul";
    case Calendar.AUGUST:
        return "Aug";
    case Calendar.SEPTEMBER:
        return "Sep";
    case Calendar.OCTOBER:
        return "Oct";
    case Calendar.NOVEMBER:
        return "Nov";
    case Calendar.DECEMBER:
        return "Dec";
    default://from w  ww  .ja v  a2  s  .  com
        return "";
    }
}

From source file:Main.java

public static int getSemester() {
    Calendar cal = Calendar.getInstance();

    int month = cal.get(Calendar.MONTH);

    if (month > Calendar.FEBRUARY && month < Calendar.SEPTEMBER)
        return SUMMER_SEMESTER;
    else//from  ww  w. jav a  2s. c  o  m
        return WINTER_SEMESTER;
}

From source file:Main.java

public static int getDaysInMonth(int month, int year) {
    switch (month) {
    case Calendar.JANUARY:
    case Calendar.MARCH:
    case Calendar.MAY:
    case Calendar.JULY:
    case Calendar.AUGUST:
    case Calendar.OCTOBER:
    case Calendar.DECEMBER:
        return 31;
    case Calendar.APRIL:
    case Calendar.JUNE:
    case Calendar.SEPTEMBER:
    case Calendar.NOVEMBER:
        return 30;
    case Calendar.FEBRUARY:
        return (year % 4 == 0) ? 29 : 28;
    default://from w w w.  j  av  a 2 s  . c  o m
        throw new IllegalArgumentException("Invalid Month");
    }
}

From source file:Main.java

public static int getDaysInMonth(int month, int year) {
    switch (month) {
    case Calendar.JANUARY:
    case Calendar.MARCH:
    case Calendar.MAY:
    case Calendar.JULY:
    case Calendar.AUGUST:
    case Calendar.OCTOBER:
    case Calendar.DECEMBER:
        return 31;
    case Calendar.APRIL:
    case Calendar.JUNE:
    case Calendar.SEPTEMBER:
    case Calendar.NOVEMBER:
        return 30;
    case Calendar.FEBRUARY:
        return (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) ? 29 : 28;
    default:/*  w ww. j av a2  s. c  o m*/
        throw new IllegalArgumentException("Invalid Month");
    }
}