List of usage examples for java.util Calendar setTimeInMillis
public void setTimeInMillis(long millis)
From source file:net.mlw.vlh.adapter.hibernate3.util.setter.CalendarSetter.java
/** * <ol>//from w w w . ja v a 2 s . co m * <li>If is filter value instance of the Calendar, it will set it directly * to query. </li> * <li>If is filter value instance of String, it try to convert it it to long and set to Calendar instance</li> * <li>If is filter value instance of Long, it try to convert it it to long and set to Calendar instance</li> * <li>Otherwise it will set null to query for key.</li> * </ol> * * @see net.mlw.vlh.adapter.hibernate3.util.Setter#set(org.hibernate.Query, * java.lang.String, java.lang.Object) */ public void set(Query query, String key, Object value) throws HibernateException, ParseException { Calendar calendar = null; if (value instanceof String) { calendar = Calendar.getInstance(); try { calendar.setTimeInMillis(Long.valueOf((String) value).longValue()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("The key's='" + key + "' String value='" + value + "' was converted to Calendar."); } } catch (NumberFormatException e) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("The key's='" + key + "' String value='" + value + "' was not converted to Calendar, error was:" + e.getMessage()); } throw e; } } else if (value instanceof Long) { calendar = Calendar.getInstance(); calendar.setTimeInMillis(((Long) value).longValue()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("The key's='" + key + "' Long value='" + value + "' was converted to Calendar."); } } else if (value instanceof Calendar) { calendar = (Calendar) value; } else if (value == null) { if (LOGGER.isInfoEnabled()) { LOGGER.info("The key='" + key + "'s value is null."); } } else { if (LOGGER.isWarnEnabled()) { LOGGER.warn("The key's='" + key + "' value='" + value + "' was expected as Calendar."); } throw new IllegalArgumentException("Cannot convert value of class " + value.getClass().getName() + " to calendar (key=" + key + ")"); } query.setCalendar(key, calendar); if (LOGGER.isInfoEnabled()) { LOGGER.info("The key='" + key + "' was set to the query as Calendar='" + calendar + "'."); } }
From source file:org.n52.server.sos.generator.EESGenerator.java
private JFreeChart producePresentation(Map<String, OXFFeatureCollection> entireCollMap, DesignOptions options) throws OXFException, IOException { Calendar begin = Calendar.getInstance(); Calendar end = Calendar.getInstance(); begin.setTimeInMillis(options.getBegin()); end.setTimeInMillis(options.getEnd()); return renderer.renderChart(entireCollMap, options, begin, end, FACADE_COMPRESSION); }
From source file:com.orange.oidc.secproxy_service.Token.java
Calendar fromStringToDate(String s) { if (s != null && s.length() > 0) { try {//from www .ja v a 2 s . c o m long d = Long.parseLong(s); Calendar c = Calendar.getInstance(); c.setTimeInMillis(d * 1000); c.setTimeZone(TimeZone.getDefault()); return c; } catch (Exception e) { } } return null; }
From source file:org.n52.server.io.Generator.java
/** * @param options/* ww w . j a v a 2s. c o m*/ * the design options to read the set time from. * @return a time instance representing an ISO8601 period. */ protected ITime getTimeFrom(DesignOptions options) { Calendar beginPos = Calendar.getInstance(); beginPos.setTimeInMillis(options.getBegin()); Calendar endPos = Calendar.getInstance(); endPos.setTimeInMillis(options.getEnd()); String begin = dateFormat.format(beginPos.getTime()); String end = dateFormat.format(endPos.getTime()); return TimeFactory.createTime(begin + "/" + end); }
From source file:com.heliumv.factory.impl.ZeiterfassungCall.java
private Timestamp updateTimeWithNow(Timestamp theirsTs) { if (theirsTs == null) return null; Calendar theirs = Calendar.getInstance(); theirs.setTimeInMillis(theirsTs.getTime()); Calendar mine = Calendar.getInstance(); theirs.set(Calendar.HOUR, mine.get(Calendar.HOUR)); theirs.set(Calendar.MINUTE, mine.get(Calendar.MINUTE)); theirs.set(Calendar.SECOND, 0); return new Timestamp(theirs.getTimeInMillis()); }
From source file:com.heliumv.factory.impl.ZeiterfassungCall.java
private void modifyKommtGehtToNow(ZeitdatenDto zDto) throws RemoteException, NamingException, EJBExceptionLP { Integer taetigkeitId = zDto.getTaetigkeitIId(); if (taetigkeitId == null) return;/*from www. jav a 2s .c o m*/ if (taetigkeitId.equals(getCachedTaetigkeitId(ZeiterfassungFac.TAETIGKEIT_KOMMT)) || taetigkeitId.equals(getCachedTaetigkeitId(ZeiterfassungFac.TAETIGKEIT_GEHT)) || taetigkeitId.equals(getCachedTaetigkeitId(ZeiterfassungFac.TAETIGKEIT_UNTER))) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(System.currentTimeMillis()); c.set(Calendar.MILLISECOND, 0); c.set(Calendar.SECOND, 0); zDto.setTZeit(new Timestamp(c.getTimeInMillis())); } }
From source file:org.n52.server.io.Generator.java
protected ITime getResultTimeFrom(DesignOptions options) { if (options.getResultTime() != null) { Calendar resTime = Calendar.getInstance(); resTime.setTimeInMillis(options.getResultTime()); String resultTime = dateFormat.format(resTime.getTime()); return TimeFactory.createTime(resultTime); }//from w w w .j a v a 2 s. c o m return null; }
From source file:com.oasis.wolfburg.service.qzSchedule.handler.ClientBarcodeScheduleHandler.java
private Date getScanTime(ClientBarcodeRecord barcode) { Date scanTime = barcode.getScanTime(); if (!barcode.isOnline()) { Long mTime = barcode.getScanTime().getTime() + (barcode.getServerTime().getTime() - barcode.getOfflineUploadTime().getTime()); Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(mTime); scanTime = cal.getTime();//from ww w.j a v a 2 s .c om } return scanTime; }
From source file:org.trpr.platform.servicefw.impl.ServiceStatisticsGatherer.java
/** * Returns the ServiceStatistics array for all services deployed locally * @param clearcollectedStats boolean variable to reset the collected statistics. * @return ServiceStatistics array containing one instance per service deployed locally *//*w w w . ja va 2s.co m*/ @SuppressWarnings("rawtypes") private ServiceStatistics[] getStats(boolean clearCollectedStats) { if (serviceContainer == null) { // the service container has not been set. Return an empty array of service invocation statistics return new ServiceStatistics[0]; } ServiceKey[] serviceKeys = serviceContainer.getAllLocalServices(); ServiceStatistics[] servicesStatistics = new ServiceStatistics[serviceKeys.length]; for (int i = 0; i < serviceKeys.length; i++) { ServiceCompartment serviceCompartment = serviceContainer.getCompartment(serviceKeys[i]); servicesStatistics[i] = new ServiceStatistics(); servicesStatistics[i].setServiceName(serviceKeys[i].getName()); servicesStatistics[i].setServiceVersion(serviceKeys[i].getVersion()); Calendar startupTimeStamp = Calendar.getInstance(); startupTimeStamp.setTimeInMillis(serviceCompartment.getStartupTimeStamp()); servicesStatistics[i].setStartupTimeStamp(startupTimeStamp); Calendar lastCalledTimeStamp = null; if (serviceCompartment.getLastCalledTimestamp() != ServiceCompartmentImpl.INVALID_STATISTICS_VALUE) { lastCalledTimeStamp = Calendar.getInstance(); lastCalledTimeStamp.setTimeInMillis(serviceCompartment.getLastCalledTimestamp()); } servicesStatistics[i].setLastCalledTimestamp(lastCalledTimeStamp); servicesStatistics[i].setActiveRequestsCount(serviceCompartment.getActiveRequestsCount()); servicesStatistics[i].setTotalRequestsCount(serviceCompartment.getTotalRequestsCount()); servicesStatistics[i].setAverageResponseTime(serviceCompartment.getAverageResponseTime()); servicesStatistics[i].setMinimumResponseTime(serviceCompartment.getMinimumResponseTime()); servicesStatistics[i].setMaximumResponseTime(serviceCompartment.getMaximumResponseTime()); servicesStatistics[i] .setLastServiceRequestResponseTime(serviceCompartment.getLastServiceRequestResponseTime()); servicesStatistics[i].setErrorRequestsCount(serviceCompartment.getErrorRequestsCount()); servicesStatistics[i].setSuccessRequestsCount(serviceCompartment.getSuccessRequestsCount()); } return servicesStatistics; }
From source file:org.n52.server.io.EESGenerator.java
private JFreeChart producePresentation(Map<String, OXFFeatureCollection> entireCollMap, DesignOptions options) throws IOException { Calendar begin = Calendar.getInstance(); Calendar end = Calendar.getInstance(); begin.setTimeInMillis(options.getBegin()); end.setTimeInMillis(options.getEnd()); return renderer.renderChart(entireCollMap, options, begin, end, FACADE_COMPRESSION); }