List of usage examples for java.util Calendar SECOND
int SECOND
To view the source code for java.util Calendar SECOND.
Click Source Link
get
and set
indicating the second within the minute. From source file:be.fedict.eid.idp.model.applet.SecureCardReaderServiceBean.java
@Override public String getTransactionMessage() { Boolean transactionMessageSigning = this.configuration.getValue(ConfigProperty.TRANSACTION_MESSAGE_SIGNING, Boolean.class); if (null == transactionMessageSigning) { return null; }/*from www. ja va 2 s .c om*/ if (Boolean.FALSE.equals(transactionMessageSigning)) { return null; } RPEntity relyingPartyEntity = AppletUtil.getSessionAttribute(Constants.RP_SESSION_ATTRIBUTE); String applicationName; if (null != relyingPartyEntity) { applicationName = relyingPartyEntity.getName(); } else { applicationName = AppletUtil.getSessionAttribute(Constants.RP_DOMAIN_SESSION_ATTRIBUTE); } Calendar calendar = Calendar.getInstance(); String transactionMessage = applicationName + " @ " + calendar.get(Calendar.DAY_OF_MONTH) + "/" + (calendar.get(Calendar.MONTH) + 1) + "/" + calendar.get(Calendar.YEAR) + " " + calendar.get(Calendar.HOUR_OF_DAY) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND); LOG.debug("transaction message: " + transactionMessage); return transactionMessage; }
From source file:com.silverpeas.calendar.DateTimeTest.java
@Test public void createsAtASpecifiedDateTime() { Calendar now = getInstance(); DateTime expected = new DateTime(now.getTime()); DateTime actual = DateTime.dateTimeAt(now.get((Calendar.YEAR)), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH), now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND), now.get(Calendar.MILLISECOND)); assertEquals(expected.getTime(), actual.getTime(), 100); }
From source file:com.evolveum.midpoint.repo.sql.CleanupTest.java
License:asdf
private Calendar create_2013_07_12_12_00_Calendar() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, 2013); calendar.set(Calendar.MONTH, Calendar.MAY); calendar.set(Calendar.DAY_OF_MONTH, 7); calendar.set(Calendar.HOUR_OF_DAY, 12); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar; }
From source file:TimeLib.java
/** * Based on code posted at//www . j a v a2s . co m * http://forum.java.sun.com/thread.jspa?threadID=488676&messageID=2292012 */ private static int estimateUnitsBetween(long t0, long t1, int field) { long d = t1 - t0; switch (field) { case Calendar.MILLISECOND: return (int) d; // this could be very inaccurate. TODO: use long instead of int? case Calendar.SECOND: return (int) (d / SECOND_MILLIS + .5); case Calendar.MINUTE: return (int) (d / MINUTE_MILLIS + .5); case Calendar.HOUR_OF_DAY: case Calendar.HOUR: return (int) (d / HOUR_MILLIS + .5); case Calendar.DAY_OF_WEEK_IN_MONTH: case Calendar.DAY_OF_MONTH: // case Calendar.DATE : // codes to same int as DAY_OF_MONTH return (int) (d / DAY_MILLIS + .5); case Calendar.WEEK_OF_YEAR: return (int) (d / WEEK_MILLIS + .5); case Calendar.MONTH: return (int) (d / MONTH_MILLIS + .5); case Calendar.YEAR: return (int) (d / YEAR_MILLIS + .5); case DECADE: return (int) (d / DECADE_MILLIS + .5); case CENTURY: return (int) (d / CENTURY_MILLIS + .5); case MILLENIUM: return (int) (d / MILLENIUM_MILLIS + .5); default: return 0; } }
From source file:com.reizes.shiva.utils.CommonUtil.java
/** * ? ? ? ?. ? 00:00:00 //from ww w . j a v a 2s. c om * adjustAmount ? -? + ? ?, 0 ? ? */ public static Date getAdjustDayResetTime(Date date, int adjustAmount) { if (date == null) { return null; } Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.add(Calendar.DATE, adjustAmount); return cal.getTime(); }
From source file:com.haulmont.chile.core.datatypes.impl.DateDatatype.java
protected java.sql.Date normalize(java.util.Date dateTime) { Calendar cal = Calendar.getInstance(); cal.setTime(dateTime);// w ww. j a v a 2 s. c o m cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return new java.sql.Date(cal.getTimeInMillis()); }
From source file:de.csdev.ebus.command.datatypes.ext.EBusTypeDateTime.java
@Override public EBusDateTime decodeInt(byte[] data) throws EBusTypeException { IEBusType<Object> dateType = getDateType(); IEBusType<Object> timeType = getTimeType(); byte[] timeData = null; byte[] dateData = null; if (timeFirst) { timeData = Arrays.copyOf(data, timeType.getTypeLength()); dateData = Arrays.copyOfRange(data, timeData.length, timeData.length + dateType.getTypeLength()); } else {//from w w w . j a v a 2 s .co m dateData = Arrays.copyOf(data, dateType.getTypeLength()); timeData = Arrays.copyOfRange(data, dateData.length, dateData.length + timeType.getTypeLength()); } EBusDateTime time = (EBusDateTime) timeType.decode(timeData); EBusDateTime date = (EBusDateTime) dateType.decode(dateData); Calendar calendar = date.getCalendar(); calendar.set(Calendar.HOUR_OF_DAY, time.getCalendar().get(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, time.getCalendar().get(Calendar.MINUTE)); calendar.set(Calendar.SECOND, time.getCalendar().get(Calendar.SECOND)); return new EBusDateTime(calendar, false, false); }
From source file:de.laures.cewolf.taglib.ChartImageDefinition.java
/** * Constructor for ChartImage/*from w ww .j a va 2 s . co m*/ */ public ChartImageDefinition(ChartHolder ch, int width, int height, int type, String mimeType, int timeout) { if (width <= 0) { throw new IllegalArgumentException("ChartImage with height or width <= 0 is illegal"); } this.chartHolder = ch; this.width = width; this.height = height; this.type = type; this.mimeType = mimeType; Calendar cal = new GregorianCalendar(); cal.add(Calendar.SECOND, timeout); this.timeoutTime = cal.getTime(); }
From source file:nl.xillio.gitbreakers.procrastimaster.server.services.UpdateService.java
private void setNextWorkingDayToMidnight(Update entity) { Calendar calendar = new GregorianCalendar(); calendar.setTime(entity.getNextDay()); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); entity.setNextDay(calendar.getTime()); }
From source file:emily.util.YTUtil.java
/** * Time until the next google api reset happens (Midnight PT), or 9am GMT * * @return formatted string, eg. "10 minutes form now" *///from w w w .j av a 2s. com public static String nextApiResetTime() { Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_MONTH, 0); c.set(Calendar.HOUR_OF_DAY, 9); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return TimeUtil.getRelativeTime( (System.currentTimeMillis() + (c.getTimeInMillis() - System.currentTimeMillis()) % TimeUnit.DAYS.toMillis(1)) / 1000L, false); }