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:com.jennifer.ui.util.TimeUtil.java
public static Date add(Date d, String type, int interval) { Calendar c = Calendar.getInstance(); c.setTime(d);//from w w w . j ava 2 s . co m if (Time.YEARS.equals(type)) { c.add(Calendar.YEAR, interval); } else if (Time.MONTHS.equals(type)) { c.add(Calendar.MONTH, interval); } else if (Time.DAYS.equals(type)) { c.add(Calendar.DATE, interval); } else if (Time.HOURS.equals(type)) { c.add(Calendar.HOUR_OF_DAY, interval); } else if (Time.MINUTES.equals(type)) { c.add(Calendar.MINUTE, interval); } else if (Time.SECONDS.equals(type)) { c.add(Calendar.SECOND, interval); } else if (Time.MILLISECONDS.equals(type)) { c.add(Calendar.MILLISECOND, interval); } else if (Time.WEEKS.equals(type)) { c.add(Calendar.DATE, interval * 7); } return c.getTime(); }
From source file:com.intuit.wasabi.assignmentobjects.DateHour.java
public void setDateHour(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w ww .j ava2 s . c om*/ cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); this.day_hour = cal.getTime(); }
From source file:com.wanikani.wklib.UserInformation.java
private static Calendar getNormalizedCalendar(Date date) { Calendar ans;/* w ww. j ava 2 s. c o m*/ ans = Calendar.getInstance(); ans.setTime(date); ans.set(Calendar.HOUR, 1); ans.set(Calendar.MINUTE, 2); ans.set(Calendar.SECOND, 3); ans.set(Calendar.MILLISECOND, 4); return ans; }
From source file:Main.java
/** * @param date/*from ww w.ja v a2 s . com*/ * @return */ public static String encodeTime(Date date) { StringBuilder result = new StringBuilder("T_"); Calendar cal = Calendar.getInstance(); cal.setTime(date); int month = cal.get(Calendar.MONTH) + 1; int year = cal.get(Calendar.YEAR); int day = cal.get(Calendar.DAY_OF_MONTH); int hour = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); int second = cal.get(Calendar.SECOND); //yyyy-MM-DD'T'kk:mm:ss result.append(year).append("-").append((month < 10) ? "0" : "").append(month).append("-") .append((day < 10) ? "0" : "").append(day).append("T").append((hour < 10) ? "0" : "").append(hour) .append(":").append((minute < 10) ? "0" : "").append(minute).append(":") .append((second < 10) ? "0" : "").append(second); return result.toString(); }
From source file:DateUtils.java
public static String getTime() { Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); int hours = cal.get(Calendar.HOUR_OF_DAY); // use 24 hour clock int minutes = cal.get(Calendar.MINUTE); int seconds = cal.get(Calendar.SECOND); int milli = cal.get(Calendar.MILLISECOND); return formatTime(hours, minutes, seconds, milli); }
From source file:com.my373.common.util.MyDateUtils.java
/** * /*ww w . j a v a 2s . c om*/ * * @param calendar * @return */ public static Calendar setTimeToMidnight(Calendar calendar) { calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); return calendar; }
From source file:com.worldline.easycukes.rest.utils.DateHelper.java
/** * Used to convert date value in json date format * * @param value/*from w w w .j a v a2s .c om*/ * @return */ public static String convertDateToJsonFormat(@NonNull final Date value) { log.info("setting the date value " + value + " to format json"); final Calendar calendar = Calendar.getInstance(); calendar.setTime(value); return calendar.get(Calendar.YEAR) + "-" + formatTo2Digit(calendar.get(Calendar.MONTH) + 1) + "-" + formatTo2Digit(calendar.get(Calendar.DAY_OF_MONTH)) + "T" + formatTo2Digit(calendar.get(Calendar.HOUR_OF_DAY)) + ":" + formatTo2Digit(calendar.get(Calendar.MINUTE)) + ":" + formatTo2Digit(calendar.get(Calendar.SECOND)) + ":" + calendar.get(Calendar.MILLISECOND) + "Z"; }
From source file:ezbake.services.provenance.graph.Utils.java
public static ezbake.base.thrift.DateTime convertDate2DateTime(final java.util.Date theDate) { final Calendar cal = new GregorianCalendar(); cal.setTime(theDate);/*from w w w . j av a 2 s. co m*/ // get calendar parts final int year = cal.get(Calendar.YEAR); final int month = cal.get(Calendar.MONTH) + 1; final int day = cal.get(Calendar.DAY_OF_MONTH); final int hour = cal.get(Calendar.HOUR_OF_DAY); final int minute = cal.get(Calendar.MINUTE); final int second = cal.get(Calendar.SECOND); int offsetMinutes = (cal.getTimeZone().getOffset(cal.getTimeInMillis())) / (1000 * 60); // set thrift DateTime propertiesd final ezbake.base.thrift.DateTime dt = new ezbake.base.thrift.DateTime(); // Date final ezbake.base.thrift.Date date = new ezbake.base.thrift.Date(); date.setMonth((short) month).setDay((short) day).setYear((short) year); dt.setDate(date); // Time with TimeZone final ezbake.base.thrift.Time t = new ezbake.base.thrift.Time(); boolean afterUtc = offsetMinutes > 0; offsetMinutes = Math.abs(offsetMinutes); final ezbake.base.thrift.TimeZone tz = new ezbake.base.thrift.TimeZone((short) (offsetMinutes / 60), (short) (offsetMinutes % 60), afterUtc); t.setHour((short) hour).setMinute((short) minute).setSecond((short) second).setTz(tz); dt.setTime(t); return dt; }
From source file:com.qpark.eip.core.spring.statistics.impl.SysUserStatisticsChannelInvocationListener.java
/** * Get a {@link Date}, where hours, minutes, seconds and milliseconds are * set to 0./*from w w w. ja v a2 s. co m*/ * * @return the {@link Date} and the corresponding log string. */ public static Calendar getRequestDate() { Calendar gc = new GregorianCalendar(LOGGING_TIMEZONE); gc.set(Calendar.HOUR_OF_DAY, 0); gc.set(Calendar.MINUTE, 0); gc.set(Calendar.SECOND, 0); gc.set(Calendar.MILLISECOND, 0); return gc; }
From source file:com.qpark.eip.core.spring.statistics.dao.StatisticsEraser.java
/** * Each day at 0:00 remove old out dated entries. *//* ww w . j av a2 s . c o m*/ @Scheduled(cron = "0 0 0 * * *") public void erase() { Calendar gc = new GregorianCalendar(); gc.set(Calendar.HOUR_OF_DAY, 0); gc.set(Calendar.MINUTE, 0); gc.set(Calendar.SECOND, 0); gc.set(Calendar.MILLISECOND, 0); gc.add(Calendar.WEEK_OF_YEAR, -1 * Math.abs(this.numberOfWeeksToKeepLogs)); this.dao.eraseSystemUserLog(gc.getTime()); this.dao.eraseApplicationUserLog(gc.getTime()); this.dao.eraseFlowLogMessage(gc.getTime()); }