List of usage examples for java.util Calendar getInstance
public static Calendar getInstance()
From source file:Main.java
public static int[] formatTimeToArray(long time) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(time);/* ww w .j ava2 s . c o m*/ int hour = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); return new int[] { hour, minute }; }
From source file:Main.java
public static String createCCPFileName() { Calendar c = Calendar.getInstance(); c.setTimeInMillis(System.currentTimeMillis()); int y = c.get(Calendar.YEAR); int m = c.get(Calendar.MONTH); int d = c.get(Calendar.DAY_OF_MONTH); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); int second = c.get(Calendar.SECOND); return y + "-" + m + "-" + d + "-" + hour + "-" + minute + "-" + second; }
From source file:Main.java
public static int getMonth() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); int year = c.get(Calendar.MONTH); return year;/*from w w w. ja va 2 s . c o m*/ }
From source file:Main.java
public static boolean isToday(Calendar calendar) { Calendar today = Calendar.getInstance(); return today.get(Calendar.YEAR) == calendar.get(Calendar.YEAR) && today.get(Calendar.MONTH) == calendar.get(Calendar.MONTH) && today.get(Calendar.DAY_OF_MONTH) == calendar.get(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static String getClockTimeFromSeconds(long secs) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(secs * 1000L);//from w w w . jav a2s . c om return String.format("%02d:%02d", c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE)); }
From source file:Main.java
public static int getMinute() { Calendar cal = Calendar.getInstance(); Date date = cal.getTime(); return date.getMinutes(); }
From source file:Main.java
public static long getMinTimeStampForIgMedia() { Calendar rightNow = Calendar.getInstance(); rightNow.add(Calendar.DAY_OF_YEAR, -2); return rightNow.getTimeInMillis() / 1000; }
From source file:Main.java
public static Calendar createCalendar(long time) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time);/*from w ww . ja v a 2 s. c o m*/ return calendar; }
From source file:Main.java
public static String getHour(long time) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(time);/*from ww w.jav a2 s . c o m*/ int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); String times = "" + hour; if (minute < 10) { times += ":0" + minute; } else { times += ":" + minute; } return times; }
From source file:Util.java
public static Date getLastMonthLastDate() { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MONTH, -1); int max = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); calendar.set(Calendar.DAY_OF_MONTH, max); return calendar.getTime(); }