List of usage examples for java.util Calendar MINUTE
int MINUTE
To view the source code for java.util Calendar MINUTE.
Click Source Link
get
and set
indicating the minute within the hour. From source file:Main.java
public static String getCurrent() { Calendar calender = Calendar.getInstance(); String minute = ""; if (calender.get(Calendar.MINUTE) < 10) { minute = 0 + "" + calender.get(Calendar.MINUTE); } else {/*from w w w . j a va2 s.c o m*/ minute = "" + calender.get(Calendar.MINUTE); } String created = calender.get(Calendar.YEAR) % 100 + "/" + (calender.get(Calendar.MONTH) + 1) + "/" + calender.get(Calendar.DAY_OF_MONTH) + " " + calender.get(Calendar.HOUR_OF_DAY) + ":" + minute + ""; return created; }
From source file:Main.java
public static String getHour(long time) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(time);/*from www . ja va2s. co 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:Main.java
public static Calendar getFirstDayOfWeek() { Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0);/*from w ww. j a va2s . co m*/ cal.set(Calendar.MILLISECOND, 0); return cal; }
From source file:Main.java
public static Date dayBegin(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date);//from w w w. ja va2 s. c o m c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return c.getTime(); }
From source file:Main.java
public static int getMinute(Date date) { calendar = Calendar.getInstance(); calendar.setTime(date);/* ww w. jav a 2s.c o m*/ return calendar.get(Calendar.MINUTE); }
From source file:Main.java
public static int[] formatTimeToArray(long time) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(time);//from w ww . ja va 2 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
/** * keep year, month & day of calendar * * @param c calendar to be clear/* ww w . jav a 2s .com*/ */ public static void clearCalendarOffset(Calendar c) { c.set(Calendar.MILLISECOND, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.HOUR_OF_DAY, 0); }
From source file:Main.java
public static String millisToDate(long currentTime) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(currentTime); return calendar.get(Calendar.HOUR) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND) + " " + (calendar.get(Calendar.AM_PM) == 0 ? "AM" : "PM"); }
From source file:Main.java
public static long getDayInUTC(long time) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(time);//from www.j a v a 2s . co m cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); cal.setTimeZone(TimeZone.getTimeZone("UTC")); return cal.getTimeInMillis(); }
From source file:Main.java
public static void timeStamp(String tag) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); System.out.println("time stamp - " + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND) + ":" + calendar.get(Calendar.MILLISECOND) + " -- " + tag); }