List of usage examples for java.util Calendar ERA
int ERA
To view the source code for java.util Calendar ERA.
Click Source Link
get
and set
indicating the era, e.g., AD or BC in the Julian calendar. From source file:Main.java
public static void main(String[] args) { GregorianCalendar cal = new GregorianCalendar(); cal.set(Calendar.ERA, GregorianCalendar.BC); System.out.println(cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { GregorianCalendar cal = new GregorianCalendar(); cal.set(Calendar.ERA, GregorianCalendar.AD); System.out.println(cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); System.out.println(now.getTime()); System.out.println(now.get(Calendar.ERA)); }
From source file:JapaneseCalendar.java
public static void main(String args[]) { Locale locale = new Locale("ja", "JP", "JP"); Calendar now = Calendar.getInstance(locale); Map<String, Integer> names = now.getDisplayNames(Calendar.ERA, Calendar.LONG, locale); System.out.printf("%s%n", names); System.out.printf("It is year %tY of the current era%n", now); System.out.printf("The calendar class is: %s%n", now.getClass().getName()); }
From source file:MainClass.java
public static void main(String[] a) { Calendar calendar = new GregorianCalendar(); calendar.setTime(new Date()); System.out.println("ERA: " + calendar.get(Calendar.ERA)); System.out.println("YEAR: " + calendar.get(Calendar.YEAR)); System.out.println("MONTH: " + calendar.get(Calendar.MONTH)); System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR)); System.out.println("WEEK_OF_MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH)); System.out.println("DATE: " + calendar.get(Calendar.DATE)); System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH)); System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK)); System.out.println("DAY_OF_WEEK_IN_MONTH: " + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH)); System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM)); System.out.println("MILLISECOND: " + calendar.get(Calendar.MILLISECOND)); System.out.println("ZONE_OFFSET: " + (calendar.get(Calendar.ZONE_OFFSET) / (60 * 60 * 1000))); System.out.println("DST_OFFSET: " + (calendar.get(Calendar.DST_OFFSET) / (60 * 60 * 1000))); }
From source file:DatePrint1.java
public static void main(String[] argv) { //+// w w w . ja va 2 s. co m Calendar c = new GregorianCalendar(1918, 10, 11); System.out.println(c.get(Calendar.DAY_OF_MONTH) + " " + c.get(Calendar.MONTH) + ", " + c.get(Calendar.YEAR) + " " + c.get(Calendar.ERA)); //- }
From source file:Main.java
public static boolean isSameMonth(Calendar c1, Calendar c2) { if (c1 == null || c2 == null) return false; return (c1.get(Calendar.ERA) == c2.get(Calendar.ERA) && c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR) && c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH)); }
From source file:Main.java
public static boolean isSameDay(Calendar cal1, Calendar cal2) { if (cal1 == null || cal2 == null) throw new IllegalArgumentException("The dates must not be null"); return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)); }
From source file:Main.java
/** * * @param c1/*from w w w. ja va2s . c o m*/ * @param c2 * @return */ public static boolean isSameMonth(Calendar c1, Calendar c2) { return !(c1 == null || c2 == null) && (c1.get(Calendar.ERA) == c2.get(Calendar.ERA) && (c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR)) && (c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH))); }
From source file:Main.java
public static boolean isSameDay(Calendar cal1, Calendar cal2) { if (cal1 == null || cal2 == null) { throw new IllegalArgumentException("The date must not be null"); }// w w w. jav a2 s. com return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)); }