List of usage examples for java.util Calendar getInstance
public static Calendar getInstance()
From source file:MainClass.java
public static void main(String args[]) { Calendar calendar = Calendar.getInstance(); System.out.println(calendar.get(Calendar.YEAR)); System.out.println(calendar.get(Calendar.HOUR)); System.out.println(calendar.get(Calendar.HOUR_OF_DAY)); System.out.println(calendar.get(Calendar.MINUTE)); }
From source file:MainClass.java
public static void main(String args[]) { Formatter fmt = new Formatter(); Calendar cal = Calendar.getInstance(); // ./*from w ww . j av a2s .com*/ fmt = new Formatter(); fmt.format("%tl:%tM", cal, cal); System.out.println(fmt); }
From source file:Test.java
public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); if (calendar.isWeekDateSupported()) { System.out.println("Number of weeks in this year: " + calendar.getWeeksInWeekYear()); System.out.println("Current week number: " + calendar.get(Calendar.WEEK_OF_YEAR)); }//from www .j a va 2s. com calendar.setWeekDate(2012, 16, 3); System.out.println( DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime())); }
From source file:MainClass.java
public static void main(String args[]) { Formatter fmt = new Formatter(); Calendar cal = Calendar.getInstance(); fmt = new Formatter(); fmt.format("%tc", cal); System.out.println(fmt);//from w w w. j a v a 2s. c o m }
From source file:Main.java
public static void main(String[] argv) throws Exception { Calendar local = Calendar.getInstance(); Calendar japanCal = new GregorianCalendar(TimeZone.getTimeZone("Japan")); japanCal.setTimeInMillis(local.getTimeInMillis()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Formatter fmt = new Formatter(); Calendar cal = Calendar.getInstance(); System.out.println(fmt.format("Short date format: %tD\n", cal)); }
From source file:Main.java
public static void main(String[] args) { // create a new calendar Calendar cal = Calendar.getInstance(); // print the first day of the week System.out.println("First day is :" + cal.getFirstDayOfWeek()); int day = cal.getFirstDayOfWeek(); switch (day) { case (1)://from ww w .ja v a2 s. c om System.out.println("Sunday"); break; case (2): System.out.println("Monday"); break; case 3: System.out.println("Tuesday"); break; case 4: System.out.println("Wednesday"); break; case 5: System.out.println("Thrusday"); break; case 6: System.out.println("Friday"); break; case 7: System.out.println("Saturday"); break; } }
From source file:Main.java
public static void main(String[] argv) throws Exception { Formatter fmt = new Formatter(); Calendar cal = Calendar.getInstance(); fmt.format("Hour and Minute: %tl:%1$tM %1$Tp\n", cal); // Display the formatted times and dates. System.out.println(fmt);//from w w w . jav a 2s.c om }
From source file:Main.java
public static void main(String[] args) { Date date = Calendar.getInstance().getTime(); // Display a date in day, month, year format DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); String today = formatter.format(date); System.out.println("Today : " + today); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Formatter fmt = new Formatter(); Calendar cal = Calendar.getInstance(); fmt.format("Time using 24-hour clock: %tT\n", cal); System.out.println(fmt);// w w w. j a va 2s . c om }