List of usage examples for java.util Calendar APRIL
int APRIL
To view the source code for java.util Calendar APRIL.
Click Source Link
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"); }//w ww . j a va 2 s. com 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:GregCalDemo.java
public static void main(String[] av) { //+//from w w w. j a v a 2 s. c om GregorianCalendar d1 = new GregorianCalendar(1986, 04, 05); // May 5 GregorianCalendar d2 = new GregorianCalendar(); // today Calendar d3 = Calendar.getInstance(); // today System.out.println("It was then " + d1.getTime()); System.out.println("It is now " + d2.getTime()); System.out.println("It is now " + d3.getTime()); d3.set(Calendar.YEAR, 1915); d3.set(Calendar.MONTH, Calendar.APRIL); d3.set(Calendar.DAY_OF_MONTH, 12); System.out.println("D3 set to " + d3.getTime()); //- }
From source file:com.discursive.jccook.lang.builders.reflect.PoliticalCandidate.java
public static void main(String[] args) { // START lang-ex-sample-1 // Create a State State va = new State("VA", "Virginia"); // Create a Birth Date Calendar calendar = new GregorianCalendar(); calendar.set(Calendar.YEAR, 1743); calendar.set(Calendar.MONTH, Calendar.APRIL); calendar.set(Calendar.DAY_OF_MONTH, 13); Date dob = calendar.getTime(); BigDecimal moneyRaised = new BigDecimal(293829292.93); // Create a Political Candidate PoliticalCandidate candidate = new PoliticalCandidate("Jefferson", "Thomas", dob, moneyRaised, va); System.out.println(candidate); // END lang-ex-sample-1 }
From source file:com.discursive.jccook.lang.builders.customized.PoliticalCandidate.java
public static void main(String[] args) { // Create a State State va = new State("VA", "Virginia"); // Create a Birth Date Calendar calendar = new GregorianCalendar(); calendar.set(Calendar.YEAR, 1743); calendar.set(Calendar.MONTH, Calendar.APRIL); calendar.set(Calendar.DAY_OF_MONTH, 13); Date dob = calendar.getTime(); BigDecimal moneyRaised = new BigDecimal(293829292.93); // Create a Political Candidate PoliticalCandidate candidate = new PoliticalCandidate("Jefferson", "Thomas", dob, moneyRaised, va); System.out.println(candidate); }
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:/* w w w .j a v a2s . c o m*/ return ""; } }
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:/* www .ja v 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:/*from w ww . j a va2 s . c o m*/ throw new IllegalArgumentException("Invalid Month"); } }
From source file:Main.java
public static int stringMonthToInt(@NonNull final String month) { switch (month) { case "Jan": return Calendar.JANUARY; case "Feb": return Calendar.FEBRUARY; case "Mar": return Calendar.MARCH; case "Apr": return Calendar.APRIL; case "May": return Calendar.MAY; case "Jun": return Calendar.JUNE; case "Jul": return Calendar.JULY; case "Aug": return Calendar.AUGUST; case "Sep": return Calendar.SEPTEMBER; case "Oct": return Calendar.OCTOBER; case "Nov": return Calendar.NOVEMBER; case "Dec": return Calendar.DECEMBER; default://from w w w .j a v a 2 s . c o m return 0; } }
From source file:Main.java
public static int getMonth(String str) { if (str.equals("jan")) return Calendar.JANUARY; if (str.equals("feb")) return Calendar.FEBRUARY; if (str.equals("mar")) return Calendar.MARCH; if (str.equals("apr")) return Calendar.APRIL; if (str.equals("may")) return Calendar.MAY; if (str.equals("jun")) return Calendar.JUNE; if (str.equals("jul")) return Calendar.JULY; if (str.equals("aug")) return Calendar.AUGUST; if (str.equals("sep")) return Calendar.SEPTEMBER; if (str.equals("oct")) return Calendar.OCTOBER; if (str.equals("nov")) return Calendar.NOVEMBER; if (str.equals("dec")) return Calendar.DECEMBER; return -1;/* w w w. j av a 2 s.c o m*/ }
From source file:Util.java
private static int getMonthLastDate(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; default: // Calendar.FEBRUARY return year % 4 == 0 ? 29 : 28; }// w ww. ja v a 2 s . co m }