List of usage examples for java.util Calendar getInstance
public static Calendar getInstance()
From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); // // w ww . j av a2 s.c o m System.out.println("Current Year is : " + now.get(Calendar.YEAR)); // month start from 0 to 11 System.out.println("Current Month is : " + (now.get(Calendar.MONTH) + 1)); System.out.println("Current Date is : " + now.get(Calendar.DATE)); }
From source file:MainClass.java
public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); // get the hash code and print it int i = cal.hashCode(); System.out.println("A hash code for this calendar is: " + i); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); // print the minimum value for years int min = cal.getMinimum(Calendar.YEAR); System.out.println("Minimum Years: " + min); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); // tells whether date/time interpretation is lenient. boolean b = cal.isLenient(); System.out.println(b);//from w w w . j a v a2 s.c o m }
From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); System.out.println("Current time : " + now.get(Calendar.HOUR_OF_DAY) + ":" + now.get(Calendar.MINUTE) + ":" + now.get(Calendar.SECOND)); now = Calendar.getInstance(); now.add(Calendar.MINUTE, -50); System.out.println("Time before 50 minutes : " + now.get(Calendar.HOUR_OF_DAY) + ":" + now.get(Calendar.MINUTE) + ":" + now.get(Calendar.SECOND)); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); System.out.println("Today : " + cal.getTime()); // Subtract 30 days from the calendar cal.add(Calendar.DATE, -30);//w ww .jav a2 s . co m System.out.println("30 days ago: " + cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); System.out.println("Today : " + cal.getTime()); // Substract 30 days from the calendar cal.add(Calendar.DATE, -30);/*from w w w . ja v a 2 s.co m*/ System.out.println("30 days ago: " + cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); System.out.println("Current date : " + (now.get(Calendar.MONTH) + 1) + "-" + now.get(Calendar.DATE) + "-" + now.get(Calendar.YEAR)); now.add(Calendar.MONTH, 10);// w ww. j av a 2s . c o m System.out.println("date after 10 months : " + (now.get(Calendar.MONTH) + 1) + "-" + now.get(Calendar.DATE) + "-" + now.get(Calendar.YEAR)); }
From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); System.out.println("Current Hour in 12 hour format is : " + now.get(Calendar.HOUR)); System.out.println("Current Hour in 24 hour format is : " + now.get(Calendar.HOUR_OF_DAY)); System.out.println("Current Minute is : " + now.get(Calendar.MINUTE)); System.out.println("Current Second is : " + now.get(Calendar.SECOND)); System.out.println("Current Millisecond is : " + now.get(Calendar.MILLISECOND)); }