List of usage examples for org.joda.time.format DateTimeFormat fullDateTime
public static DateTimeFormatter fullDateTime()
From source file:org.codehaus.httpcache4j.cache.SerializableCacheItem.java
License:Open Source License
private SerializableCacheItem fromJSON(String json) { ObjectMapper mapper = new ObjectMapper(); try {/*from w ww .j a va 2s. co m*/ JsonNode node = mapper.readTree(json); DateTime time = DateTimeFormat.fullDateTime().parseDateTime(node.path("cache-time").getValueAsText()); Status status = Status.valueOf(node.path("status").getIntValue()); Headers headers = Headers.fromJSON(node.path("headers").getValueAsText()); CleanableFilePayload p = null; if (node.path("payload") != null) { JsonNode payload = node.path("payload"); if (!payload.isNull()) { p = new CleanableFilePayload(new File(payload.path("file").getValueAsText()), MIMEType.valueOf(payload.path("mime-type").getValueAsText())); } } return new SerializableCacheItem(new HTTPResponse(p, status, headers), time); } catch (IOException e) { throw new IllegalStateException(e); } }
From source file:org.dataconservancy.ui.stripes.BaseActionBean.java
License:Apache License
EventContext getEventContext() { EventContext eventContext = new EventContext(); final HttpServletRequest req = getContext().getRequest(); eventContext.setRequestUri(req.getRequestURI()); // Handle requests that may have been proxied by Apache http mod_proxy; don't report the proxy server // information, report the client's information if (req.getHeader(X_FORWARDED_FOR) != null) { eventContext.setOriginIp(req.getHeader(X_FORWARDED_FOR)); } else {//w w w . j a v a2 s.c om eventContext.setOriginIp(req.getRemoteAddr()); } if (req.getHeader(X_FORWARDED_HOST) != null) { eventContext.setHostName(req.getHeader(X_FORWARDED_HOST)); } else { eventContext.setHostName(req.getServerName()); } if (buildContext != null) { eventContext.setBuildDate(buildContext.getBuildTimeStamp()); eventContext.setBuildNumber(buildContext.getBuildNumber()); eventContext.setRevisionNumber(buildContext.getBuildRevision()); } else { eventContext.setBuildDate("Unknown"); eventContext.setBuildNumber("Unknown"); eventContext.setRevisionNumber("Unknown"); } eventContext.setEventDate(DateTime.now().toString(DateTimeFormat.fullDateTime())); eventContext.setActionBean(this.getClass().getName()); eventContext.setUser((getAuthenticatedUser() != null) ? getAuthenticatedUser().getEmailAddress() : "No authenticated user."); return eventContext; }
From source file:org.dataconservancy.ui.stripes.UiExceptionHandler.java
License:Apache License
/** * Creates an event and event context representing the exception, and fires it. * * @param t the exception in question * @param bean the action bean which the exception came from, may be null * @param req the HttpServletRequest/*from w w w . j a v a2s .co m*/ */ private void createAndFireEvent(Throwable t, ActionBean bean, HttpServletRequest req) { injectSpringBeans(); if (eventManager != null) { EventContext eventContext = new EventContext(); eventContext.setRequestUri(req.getRequestURI()); eventContext.setEventClass(EventClass.EXCEPTION); // Handle requests that may have been proxied by Apache http mod_proxy; don't report the proxy server // information, report the client's information if (req.getHeader(X_FORWARDED_FOR) != null) { eventContext.setOriginIp(req.getHeader(X_FORWARDED_FOR)); } else { eventContext.setOriginIp(req.getRemoteAddr()); } if (req.getHeader(X_FORWARDED_HOST) != null) { eventContext.setHostName(req.getHeader(X_FORWARDED_HOST)); } else { eventContext.setHostName(req.getServerName()); } if (buildContext != null) { eventContext.setBuildDate(buildContext.getBuildTimeStamp()); eventContext.setBuildNumber(buildContext.getBuildNumber()); eventContext.setRevisionNumber(buildContext.getBuildRevision()); } else { eventContext.setBuildDate("Unknown"); eventContext.setBuildNumber("Unknown"); eventContext.setRevisionNumber("Unknown"); } eventContext.setEventDate(DateTime.now().toString(DateTimeFormat.fullDateTime())); if (bean != null) { eventContext.setActionBean(bean.getClass().getName()); if (bean instanceof BaseActionBean) { try { eventContext.setUser(((BaseActionBean) bean).getAuthenticatedUser().getId()); } catch (NullPointerException e) { eventContext.setUser("no authenticated user"); } } } eventManager.fire(eventContext, new ExceptionEvent(eventContext, t)); } else { final String msg = "Event manager was null! Events will not be fired!"; throw new RuntimeException(msg); } }
From source file:org.emonocot.harvest.media.ImageMetadataExtractorImpl.java
License:Open Source License
public ImageMetadataExtractorImpl() { dateTimeFormatters.add(ISODateTimeFormat.dateTimeParser()); dateTimeFormatters.add(DateTimeFormat.fullDate()); dateTimeFormatters.add(DateTimeFormat.fullDateTime()); dateTimeFormatters.add(DateTimeFormat.shortDate()); dateTimeFormatters.add(DateTimeFormat.shortDateTime()); dateTimeFormatters.add(DateTimeFormat.mediumDate()); dateTimeFormatters.add(DateTimeFormat.mediumDateTime()); }
From source file:org.jevis.jecalc.CalcJobFactory.java
CalcJob getCurrentCalcJob(SampleHandler sampleHandler) { JEVisObject jevisObject = calcObjectStack.pop(); logger.info("-------------------------------------------"); logger.info("Create calc job for object with jevis id {}", jevisObject.getID()); sampleHandler.getLastSample(jevisObject, Calculation.EXPRESSION.getName()); String expression = sampleHandler.getLastSampleAsString(jevisObject, Calculation.EXPRESSION.getName()); List<JEVisAttribute> outputAttributes = getAllOutputAttributes(jevisObject); logger.debug("{} outputs found", outputAttributes.size()); DateTime startTime = getStartTimeFromOutputs(outputAttributes); logger.debug("start time is", startTime.toString(DateTimeFormat.fullDateTime())); List<CalcObject> calcObjects = getInputDataObjects(jevisObject, startTime); logger.debug("{} inputs found", calcObjects.size()); CalcJob calcJob = new CalcJob(calcObjects, expression, outputAttributes); return calcJob; }
From source file:org.jevis.jecalc.calculation.SampleMerger.java
public Map<DateTime, List<Sample>> merge() { Map<DateTime, List<Sample>> sampleMap = new TreeMap<>(); insertAllSamples(sampleMap); //value changed for every sample insertConstants(sampleMap); //value is always the same insertPeriodicConstants(sampleMap); //value changed for specific periods int variableSize = allSamples.size() + constants.size() + periodConstants.size(); Set<DateTime> removableKeys = new HashSet<>(); for (Map.Entry<DateTime, List<Sample>> sampleEntry : sampleMap.entrySet()) { if (sampleEntry.getValue().size() != variableSize) { removableKeys.add(sampleEntry.getKey()); }/*from ww w.j av a 2 s . c om*/ } for (DateTime key : removableKeys) { logger.debug("not every input data with datetime {}, will delete this datetime from calculation", key.toString(DateTimeFormat.fullDateTime())); sampleMap.remove(key); } return sampleMap; }
From source file:org.nodel.reflection.Serialisation.java
License:Mozilla Public License
private static DateTime tryParseFullDateTime(String value) { try {//from www . jav a 2 s . c o m return DateTime.parse(value, DateTimeFormat.fullDateTime()); } catch (Exception exc) { return null; } }
From source file:org.sleuthkit.autopsy.timeline.snapshot.SnapShotReportWriter.java
License:Open Source License
/** * Generate and write the html page that shows the snapshot and the state of * the ZoomParams/*from w w w . j av a2 s . c o m*/ * * @throws IOException If there is a problem writing the html file to disk. */ private void writeSnapShotHTMLFile() throws IOException { //make a map of context objects to resolve template paramaters against HashMap<String, Object> snapShotContext = new HashMap<>(); snapShotContext.put("reportTitle", reportName); //NON-NLS snapShotContext.put("startTime", zoomParams.getTimeRange().getStart().toString(DateTimeFormat.fullDateTime())); //NON-NLS snapShotContext.put("endTime", zoomParams.getTimeRange().getEnd().toString(DateTimeFormat.fullDateTime())); //NON-NLS snapShotContext.put("zoomParams", zoomParams); //NON-NLS fillTemplateAndWrite("/org/sleuthkit/autopsy/timeline/snapshot/snapshot_template.html", "Snapshot", snapShotContext, reportFolderPath.resolve("snapshot.html")); //NON-NLS }
From source file:ro.activemall.photoxserver.utils.thymeleafJoda.JodaTimeDialect.java
License:Open Source License
@Override public Set<IProcessor> getProcessors() { Set<IProcessor> processors = new HashSet<IProcessor>(); processors.add(new JodaTimeFormatProcessor("fullDate", DateTimeFormat.fullDate())); processors.add(new JodaTimeFormatProcessor("fullDateTime", DateTimeFormat.fullDateTime())); processors.add(new JodaTimeFormatProcessor("fullTime", DateTimeFormat.fullTime())); processors.add(new JodaTimeFormatProcessor("longDate", DateTimeFormat.longDate())); processors.add(new JodaTimeFormatProcessor("longDateTime", DateTimeFormat.longDateTime())); processors.add(new JodaTimeFormatProcessor("longTime", DateTimeFormat.longTime())); processors.add(new JodaTimeFormatProcessor("mediumDate", DateTimeFormat.mediumDate())); processors.add(new JodaTimeFormatProcessor("mediumDateTime", DateTimeFormat.mediumDateTime())); processors.add(new JodaTimeFormatProcessor("mediumTime", DateTimeFormat.mediumTime())); processors.add(new JodaTimeFormatProcessor("shortDate", DateTimeFormat.shortDate())); processors.add(new JodaTimeFormatProcessor("shortDateTime", DateTimeFormat.shortDateTime())); processors.add(new JodaTimeFormatProcessor("shortTime", DateTimeFormat.shortTime())); processors.add(new JodaTimeFormatProcessor("isoDateTime", ISODateTimeFormat.dateTime())); return processors; }
From source file:ro.activemall.photoxserver.utils.thymeleafJoda.JodaTimeExpressionObject.java
License:Open Source License
/** * Formats the datetime with a JodaTime full date time format * * @param dateTime//from www. j a v a 2 s. com * The datetime * @return The formatted date */ public String fullDateTime(DateTime dateTime) { return format(dateTime, DateTimeFormat.fullDateTime()); }