List of usage examples for java.util GregorianCalendar setTime
public final void setTime(Date date)
Date
. From source file:edu.duke.cabig.c3pr.web.DashboardController.java
private void getMostEnrolledStudies(HttpServletRequest request) { GregorianCalendar cal = new GregorianCalendar(); Date endDate = new Date(System.currentTimeMillis()); cal.setTime(endDate); cal.roll(Calendar.DATE, -6);/* w w w. j a va 2 s . c o m*/ Date startDate = new Date(cal.getTime().getTime()); List<Study> studiesFound = studySubjectDao.getMostEnrolledStudies(startDate, endDate); List<Study> studies = new ArrayList<Study>(); for (int i = 0; i < studiesFound.size() && i < MAX_RESULTS; i++) { studies.add(studiesFound.get(i)); } log.debug("Most enrolled studies found: " + studies.size()); request.setAttribute("aStudies", studies); }
From source file:it.cnr.icar.eric.server.persistence.rdb.AuditableEventDAO.java
@SuppressWarnings({ "rawtypes", "unchecked" }) protected void loadObject(Object obj, ResultSet rs) throws RegistryException { try {//from w w w . j a va 2s . co m if (!(obj instanceof AuditableEventType)) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.AuditableEventExpected", new Object[] { obj })); } AuditableEventType ebAuditableEventType = (AuditableEventType) obj; super.loadObject(obj, rs); //TODO: Fix so requestId is properly supported String requestId = rs.getString("requestId"); if (requestId == null) { requestId = "Unknown"; } ebAuditableEventType.setRequestId(requestId); String eventType = rs.getString("eventType"); ebAuditableEventType.setEventType(eventType); //Workaround for bug in PostgreSQL 7.2.2 JDBC driver //java.sql.Timestamp timeStamp = rs.getTimestamp("timeStamp_"); --old String timestampStr = rs.getString("timeStamp_").substring(0, 19); Timestamp timeStamp = Timestamp.valueOf(timestampStr); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(timeStamp); XMLGregorianCalendar cal = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); ebAuditableEventType.setTimestamp(cal); String userId = rs.getString("user_"); ObjectRefType ebObjectRefType = bu.rimFac.createObjectRefType(); ebObjectRefType.setId(userId); context.getObjectRefs().add(ebObjectRefType); ebAuditableEventType.setUser(userId); AffectedObjectDAO affectedDAO = new AffectedObjectDAO(context); affectedDAO.setParent(ebAuditableEventType); List affectedObjects = affectedDAO.getByParent(); ObjectRefListType orefList = BindingUtility.getInstance().rimFac.createObjectRefListType(); orefList.getObjectRef().addAll(affectedObjects); ebAuditableEventType.setAffectedObjects(orefList); } catch (SQLException e) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); throw new RegistryException(e); } catch (DatatypeConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.overlord.dtgov.ui.server.services.tasks.DtGovTaskApiClient.java
/** * Creates a {@link FindTasksRequest} from the given task inbox filter bean. * @param filters// w w w. j av a 2 s .c o m */ protected FindTasksRequest createFindTasksRequest(TaskInboxFilterBean filters) { FindTasksRequest request = new FindTasksRequest(); if (filters.getPriority() >= 0) { request.getPriority().add(filters.getPriority()); } if (filters.getDateDueFrom() != null) { DatatypeFactory dtFactory = getXmlFactory(); GregorianCalendar cal = new GregorianCalendar(); cal.setTime(filters.getDateDueFrom()); XMLGregorianCalendar from = dtFactory.newXMLGregorianCalendar(cal); request.setDueOnFrom(from); } if (filters.getDateDueTo() != null) { DatatypeFactory dtFactory = getXmlFactory(); GregorianCalendar cal = new GregorianCalendar(); cal.setTime(filters.getDateDueTo()); XMLGregorianCalendar to = dtFactory.newXMLGregorianCalendar(cal); request.setDueOnTo(to); } TaskOwnerEnum owner = filters.getOwner(); if (owner == TaskOwnerEnum.any) { request.getStatus().add(StatusType.CREATED); request.getStatus().add(StatusType.READY); request.getStatus().add(StatusType.IN_PROGRESS); request.getStatus().add(StatusType.RESERVED); } else if (owner == TaskOwnerEnum.active) { request.getStatus().add(StatusType.IN_PROGRESS); } else if (owner == TaskOwnerEnum.mine) { request.getStatus().add(StatusType.IN_PROGRESS); request.getStatus().add(StatusType.RESERVED); } else if (owner == TaskOwnerEnum.group) { request.getStatus().add(StatusType.CREATED); request.getStatus().add(StatusType.READY); } return request; }
From source file:be.fedict.eidviewer.lib.file.imports.Version35XMLFile.java
public void load(File file) throws CertificateException, FileNotFoundException, SAXException, IOException, ParseException, DataConvertorException { logger.fine("Loading Version 35X XML File"); XMLReader reader = null;/*from w w w . j a va 2s . co m*/ certificateFactory = CertificateFactory.getInstance("X.509"); DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy"); FileInputStream fis = new FileInputStream(file); reader = XMLReaderFactory.createXMLReader(); reader.setContentHandler(this); reader.setErrorHandler(this); BufferedReader in = new BufferedReader(new InputStreamReader(fis)); reader.parse(new InputSource(in)); Identity identity = new Identity(); identity.cardDeliveryMunicipality = discreteValues.get("issuing_municipality"); identity.cardNumber = discreteValues.get("logical_nr"); GregorianCalendar validityStartCalendar = new GregorianCalendar(); validityStartCalendar.setTime(dateFormat.parse(discreteValues.get("date_begin"))); identity.cardValidityDateBegin = validityStartCalendar; GregorianCalendar validityEndCalendar = new GregorianCalendar(); validityEndCalendar.setTime(dateFormat.parse(discreteValues.get("date_end"))); identity.cardValidityDateEnd = validityEndCalendar; identity.chipNumber = discreteValues.get("chip_nr"); identity.dateOfBirth = (new DateOfBirthDataConvertor()) .convert(discreteValues.get("date_of_birth").getBytes()); identity.documentType = DocumentType.toDocumentType(discreteValues.get("type").getBytes()); identity.duplicate = discreteValues.get("duplicata"); identity.gender = discreteValues.get("gender").equals("M") ? Gender.MALE : Gender.FEMALE; TextFormatHelper.setFirstNamesFromString(identity, discreteValues.get("name")); identity.name = discreteValues.get("surname"); identity.nationalNumber = discreteValues.get("national_nr"); identity.nationality = discreteValues.get("nationality"); identity.nobleCondition = discreteValues.get("nobility"); identity.placeOfBirth = discreteValues.get("location_of_birth"); identity.specialStatus = SpecialStatus.toSpecialStatus(discreteValues.get("specialStatus")); eidData.setIdentity(identity); Address address = new Address(); address.municipality = discreteValues.get("municipality"); address.zip = discreteValues.get("zip"); address.streetAndNumber = discreteValues.get("street"); eidData.setAddress(address); eidData.setPhoto(pictureData); X509Utilities.setCertificateChainsFromCertificates(eidData, rootCert, citizenCert, authenticationCert, signingCert, rrnCert); }
From source file:org.socraticgrid.hl7.ucs.nifi.common.util.MessageBuilder.java
public MessageBuilder withCreatedDate(Date createdDate) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(createdDate); this.createdDate = javax.xml.bind.DatatypeConverter.printDateTime(cal); return this; }
From source file:org.socraticgrid.hl7.ucs.nifi.common.util.MessageBuilder.java
public MessageBuilder withLastModifiedDate(Date lastModifiedDate) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(lastModifiedDate); this.lastModifiedDate = javax.xml.bind.DatatypeConverter.printDateTime(cal); return this; }
From source file:ws.michalski.sepa.pain.SEPAMessage.java
/** * /*from w w w .j a v a 2 s .c o m*/ * @throws DatatypeConfigurationException */ public SEPAMessage() { super(); log = LogFactory.getLog(SEPAMessage.class); transactionsList = new ArrayList<SEPATransaction>(); GregorianCalendar cal = new GregorianCalendar(); cal.setTime(new Date()); createDate = SEPAUtility.convert(cal); ctlSum = new BigDecimal(0); if (log.isTraceEnabled()) { log.trace("Konstruktor SEPAMessage.class"); } }
From source file:be.e_contract.mycarenet.xkms2.XKMS2Client.java
private XMLGregorianCalendar toXMLGregorianCalendar(DateTime dateTime) { GregorianCalendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.setTime(dateTime.toDate()); XMLGregorianCalendar xmlGregorianCalendar = this.datatypeFactory.newXMLGregorianCalendar(gregorianCalendar); return xmlGregorianCalendar; }
From source file:org.tolven.graph.GraphMenuEventHandler.java
private XYDataset createDataset() throws Exception { MenuPath elementPath = new MenuPath(getElement()); MenuStructure dataMS = getAction().getParent(); MenuPath mdPath = new MenuPath(dataMS.getPath(), elementPath); MenuQueryControl ctrl = new MenuQueryControl(); ctrl.setLimit(5000); // TODO: This is a hard coded hard query limit that should be in a property or something ctrl.setMenuStructure(dataMS);/*from w w w . ja va 2 s.c o m*/ ctrl.setAccountUser(getAccountUser()); ctrl.setNow(getTolvenNow()); ctrl.setOffset(0); ctrl.setOriginalTargetPath(mdPath); ctrl.setRequestedPath(mdPath); List<MenuData> menuData = getMenuBean().findMenuData(ctrl); Properties menuEventHandlerData = getAction().getMenuEventHandlerDataMap(); String timeColumn = menuEventHandlerData.getProperty("timeColumn"); String valueColumn = menuEventHandlerData.getProperty("valueColumn"); String unitsColumn = menuEventHandlerData.getProperty("unitsColumn"); String datasetColumn = menuEventHandlerData.getProperty("datasetColumn"); String[] datasetUnitsArray = getRequest().getParameter("datasetunits").split(","); List<String> datasetUnits = new ArrayList<String>(); for (String string : datasetUnitsArray) { datasetUnits.add(string); } Map<String, String[]> datasetUnitMap = createDatasetUnitsMap(); Map<String, TimeSeries> timeSeriesMap = new HashMap<String, TimeSeries>(); for (String[] datasetUnitArray : datasetUnitMap.values()) { String dataset = datasetUnitArray[0]; String unit = datasetUnitArray[1]; String datasetUnit = dataset + unit; if (datasetUnits.contains(datasetUnit)) { timeSeriesMap.put(datasetUnit, new TimeSeries(dataset + " (" + unit + ")", Hour.class)); } } for (MenuData md : menuData) { String dataset = md.getStringField(datasetColumn); String units = md.getStringField(unitsColumn); String datasetUnit = dataset + units; TimeSeries currentTimeSeries = timeSeriesMap.get(datasetUnit); if (currentTimeSeries != null) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(md.getDateField(timeColumn)); Hour hour = new Hour(cal.getTime()); currentTimeSeries.addOrUpdate(hour, md.getInternalPQValueField(md.getColumn(valueColumn).getInternal())); } } TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection(); for (TimeSeries timeSeries : timeSeriesMap.values()) { timeSeriesCollection.addSeries(timeSeries); } timeSeriesCollection.setDomainIsPointsInTime(true); TolvenLogger.info("Done preparing Dataset", GraphMenuEventHandler.class); return timeSeriesCollection; }
From source file:edu.duke.cabig.c3pr.domain.scheduler.runtime.job.CCTSNotificationMessageJob.java
private Notification convert(CCTSNotification notification) { try {/* ww w . ja v a2s. c o m*/ Notification jaxbNotification = new Notification(); jaxbNotification.setApplication(Application.C_3_PR); jaxbNotification.setEventType(EventType.fromValue(notification.getEventType())); if (notification.getTimestamp() != null) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(notification.getTimestamp()); DatatypeFactory df = DatatypeFactory.newInstance(); XMLGregorianCalendar xmlDate = df.newXMLGregorianCalendar(gc); jaxbNotification.setTimestamp(xmlDate); } BusinessObjectID businessObjectID = new BusinessObjectID(); businessObjectID.setValue(notification.getIdentifierValue()); businessObjectID.setType(notification.getIdentifierType()); jaxbNotification.setObjectId(businessObjectID); return jaxbNotification; } catch (DatatypeConfigurationException e) { throw new RuntimeException(e); } }