List of usage examples for org.joda.time.format DateTimeFormatter print
public String print(ReadablePartial partial)
From source file:nl.surfnet.coin.shared.service.ErrorMessageMailer.java
License:Apache License
private MimeMessageHelper addBody(MimeMessageHelper helper, String template, ErrorMail errorMail) throws MessagingException { DateTime dateTime = new DateTime(); DateTimeFormatter dateFormatter = DateTimeFormat.forPattern(DATE_FORMAT); DateTimeFormatter timeFormatter = DateTimeFormat.forPattern(TIME_FORMAT); String date = dateFormatter.print(dateTime); String time = timeFormatter.print(dateTime); String body = MessageFormat.format(template, date, time, errorMail.getServer(), errorMail.getComponent(), errorMail.getUserId(), errorMail.getIdp(), errorMail.getSp(), errorMail.getMessage(), errorMail.getLocation(), errorMail.getDetails()); helper.setText(body, true);/* w w w.j ava2 s . c om*/ return helper; }
From source file:nl.welteninstituut.tel.la.importers.fitbit.FitbitTask.java
License:Open Source License
private URL getHeartrateURL(DateTime start, DateTime end) throws MalformedURLException { StringBuilder sb = new StringBuilder("https://api.fitbit.com/1/user/-/activities/heart/date/"); sb.append(DateTimeFormat.forPattern("yyyy-MM-dd").print(start)); sb.append("/1d/1sec/time/"); DateTimeFormatter fitbitTimePattern = DateTimeFormat.forPattern("HH:mm"); sb.append(fitbitTimePattern.print(start)); sb.append(StringPool.SLASH);//w ww .jav a 2 s. com String endTime = fitbitTimePattern.print(end); sb.append(endTime.equals("00:00") ? "23:59" : endTime); sb.append(".json"); return new URL(sb.toString()); }
From source file:nl.welteninstituut.tel.la.importers.fitbit.FitbitTask.java
License:Open Source License
private URL getStepcountURL(DateTime start, DateTime end) throws MalformedURLException { StringBuilder sb = new StringBuilder("https://api.fitbit.com/1/user/-/activities/steps/date/"); sb.append(DateTimeFormat.forPattern("yyyy-MM-dd").print(start)); sb.append("/1d/1min/time/"); DateTimeFormatter fitbitTimePattern = DateTimeFormat.forPattern("HH:mm"); sb.append(fitbitTimePattern.print(start)); sb.append(StringPool.SLASH);//from w ww . ja v a 2 s. c om String endTime = fitbitTimePattern.print(end); sb.append(endTime.equals("00:00") ? "23:59" : endTime); sb.append(".json"); return new URL(sb.toString()); }
From source file:no.digipost.android.utilities.FileUtilities.java
License:Apache License
private static String getAttachmentFullFilename() { String fileType = DocumentContentStore.getDocumentAttachment().getFileType(); String creatorName = DocumentContentStore.getDocumentParent().getCreatorName(); String fileName = DocumentContentStore.getDocumentAttachment().getSubject(); String dateCreated = ""; try {//w ww . java2 s . c o m String tempDate = DocumentContentStore.getDocumentParent().getCreated(); DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); DateTime jodatime = dtf.parseDateTime(tempDate); DateTimeFormatter dtfOut = DateTimeFormat.forPattern("yyyy.MM.dd"); dateCreated = dtfOut.print(jodatime) + " "; } catch (Exception e) { } String fullFileName = (dateCreated + creatorName.toUpperCase() + " " + fileName + "." + fileType); fullFileName = fullFileName.replaceAll("[()\\?:!,;{}-]+", "").replaceAll("[\\t\\n\\s]+", "_"); return fullFileName; }
From source file:org.activiti.engine.impl.juel.TypeConverterImpl.java
License:Apache License
protected String coerceToString(Object value) { if (value == null) { return ""; }/* w w w. j a va 2 s .c o m*/ if (value instanceof String) { return (String) value; } if (value instanceof Enum<?>) { return ((Enum<?>) value).name(); } if (value instanceof Date) { DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); DateTime dt = new DateTime(value); return fmt.print(dt); } return value.toString(); }
From source file:org.activiti.engine.test.bpmn.event.timer.BoundaryTimerEventRepeatWithEnd.java
License:Apache License
@Deployment public void testRepeatWithEnd() throws Throwable { Calendar calendar = Calendar.getInstance(); Date baseTime = calendar.getTime(); calendar.add(Calendar.MINUTE, 20); //expect to stop boundary jobs after 20 minutes DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); DateTime dt = new DateTime(calendar.getTime()); String dateStr = fmt.print(dt); //reset the timer Calendar nextTimeCal = Calendar.getInstance(); nextTimeCal.setTime(baseTime);//from w ww . j ava 2s . com processEngineConfiguration.getClock().setCurrentTime(nextTimeCal.getTime()); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("repeatWithEnd"); runtimeService.setVariable(processInstance.getId(), "EndDateForBoundary", dateStr); List<Task> tasks = taskService.createTaskQuery().list(); assertEquals(1, tasks.size()); Task task = tasks.get(0); assertEquals("Task A", task.getName()); //Test Boundary Events // complete will cause timer to be created taskService.complete(task.getId()); List<Job> jobs = managementService.createJobQuery().list(); assertEquals(1, jobs.size()); //boundary events try { waitForJobExecutorToProcessAllJobs(2000, 200); fail("a new job must be prepared because there are 20 repeats 2 seconds interval"); } catch (Exception ex) { //expected exception because a new job is prepared } nextTimeCal.add(Calendar.MINUTE, 15); //after 15 minutes processEngineConfiguration.getClock().setCurrentTime(nextTimeCal.getTime()); try { waitForJobExecutorToProcessAllJobs(2000, 200); fail("a new job must be prepared because there are 20 repeats 2 seconds interval"); } catch (Exception ex) { //expected exception because a new job is prepared } nextTimeCal.add(Calendar.MINUTE, 5); //after another 5 minutes (20 minutes and 1 second from the baseTime) the BoundaryEndTime is reached nextTimeCal.add(Calendar.SECOND, 1); processEngineConfiguration.getClock().setCurrentTime(nextTimeCal.getTime()); try { waitForJobExecutorToProcessAllJobs(2000, 200); } catch (Exception ex) { fail("Should not have any other jobs because the endDate is reached"); } tasks = taskService.createTaskQuery().list(); task = tasks.get(0); assertEquals("Task B", task.getName()); assertEquals(1, tasks.size()); taskService.complete(task.getId()); try { waitForJobExecutorToProcessAllJobs(2000, 500); } catch (Exception e) { // expected fail("No jobs should be active here."); } }
From source file:org.akaza.openclinica.logic.expressionTree.OpenClinicaBeanVariableNode.java
License:LGPL
private Object calculateVariable() { if (number.equals("_CURRENT_DATE")) { String ssTimeZone = getExpressionBeanService().getSSTimeZone(); if (ssTimeZone == "" || ssTimeZone == null) ssTimeZone = TimeZone.getDefault().getID(); DateTimeZone ssZone = DateTimeZone.forID(ssTimeZone); DateMidnight dm = new DateMidnight(ssZone); DateTimeFormatter fmt = ISODateTimeFormat.date(); return fmt.print(dm); }/* www . ja v a 2s. c o m*/ return null; }
From source file:org.akaza.openclinica.logic.expressionTree.OpenClinicaBeanVariableNode.java
License:LGPL
private String testCalculateVariable() { if (number.equals("_CURRENT_DATE")) { String ssTimeZone = getExpressionBeanService().getSSTimeZone(); if (ssTimeZone == "" || ssTimeZone == null) ssTimeZone = TimeZone.getDefault().getID(); DateTimeZone ssZone = DateTimeZone.forID(ssTimeZone); DateMidnight dm = new DateMidnight(ssZone); DateTimeFormatter fmt = ISODateTimeFormat.date(); return fmt.print(dm); }// w ww . j av a 2 s. c om return null; }
From source file:org.akaza.openclinica.service.rule.expression.ExpressionService.java
License:LGPL
public HashMap<String, String> getSSDate(String ssZoneId, String serverZoneId) { HashMap<String, String> map = new HashMap<String, String>(); if (ssZoneId == "" || ssZoneId.equals("")) ssZoneId = TimeZone.getDefault().getID(); DateTimeZone ssZone = DateTimeZone.forID(ssZoneId); DateMidnight dm = new DateMidnight(ssZone); DateTimeFormatter fmt = ISODateTimeFormat.date(); map.put("ssDate", fmt.print(dm)); map.put("serverZoneId", serverZoneId); DateTimeZone serverZone = DateTimeZone.forID(serverZoneId); DateMidnight serverDate = new DateMidnight(serverZone); map.put("serverDate", fmt.print(serverDate)); return map;/* w w w .j ava 2 s . c om*/ }
From source file:org.apache.archiva.webdav.ArchivaDavResource.java
License:Apache License
/** * Fill the set of properties/* w w w .ja v a2 s .co m*/ */ protected DavPropertySet initProperties() { if (!exists()) { properties = new DavPropertySet(); } if (properties != null) { return properties; } DavPropertySet properties = new DavPropertySet(); // set (or reset) fundamental properties if (getDisplayName() != null) { properties.add(new DefaultDavProperty(DavPropertyName.DISPLAYNAME, getDisplayName())); } if (isCollection()) { properties.add(new ResourceType(ResourceType.COLLECTION)); // Windows XP support properties.add(new DefaultDavProperty(DavPropertyName.ISCOLLECTION, "1")); } else { properties.add(new ResourceType(ResourceType.DEFAULT_RESOURCE)); // Windows XP support properties.add(new DefaultDavProperty(DavPropertyName.ISCOLLECTION, "0")); } // Need to get the ISO8601 date for properties DateTime dt = new DateTime(localResource.lastModified()); DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); String modifiedDate = fmt.print(dt); properties.add(new DefaultDavProperty(DavPropertyName.GETLASTMODIFIED, modifiedDate)); properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE, modifiedDate)); properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTLENGTH, localResource.length())); this.properties = properties; return properties; }