List of usage examples for org.apache.commons.lang3.time DateFormatUtils ISO_DATE_FORMAT
FastDateFormat ISO_DATE_FORMAT
To view the source code for org.apache.commons.lang3.time DateFormatUtils ISO_DATE_FORMAT.
Click Source Link
From source file:com.livevox.demo.gradle.GradleService.java
/** * Format a date in yyyy-MM-dd format.//from w w w . j av a2s.c om * * @param date The date to format * @return A string with the formatted date. */ String formatDate(Date date) { return DateFormatUtils.ISO_DATE_FORMAT.format(date); }
From source file:com.livevox.demo.gradle.GradleServiceTest.java
@Test public void testFormatDate() { Date now = Calendar.getInstance().getTime(); String expected = DateFormatUtils.ISO_DATE_FORMAT.format(now); String actual = service.formatDate(now); assertEquals(expected, actual);/*from w ww .ja v a2s . c om*/ }
From source file:com.qatickets.domain.Version.java
public String getStartDateISO() { return startDate == null ? "" : DateFormatUtils.ISO_DATE_FORMAT.format(startDate); }
From source file:com.qatickets.domain.Version.java
public String getReleaseDateISO() { return releaseDate == null ? "" : DateFormatUtils.ISO_DATE_FORMAT.format(releaseDate); }
From source file:com.erudika.para.utils.Utils.java
/** * Formats a date in a specific format.// w w w . jav a 2 s .c o m * @param timestamp the Java timestamp * @param format the date format * @param loc the locale instance * @return a formatted date */ public static String formatDate(Long timestamp, String format, Locale loc) { if (StringUtils.isBlank(format)) { format = DateFormatUtils.ISO_DATE_FORMAT.getPattern(); } if (timestamp == null) { timestamp = timestamp(); } if (loc == null) { loc = Locale.US; } return DateFormatUtils.format(timestamp, format, loc); }
From source file:eu.trentorise.opendata.commons.TodUtils.java
/** * @deprecated experimental, try to avoid using it for now * @since 1.1//ww w.j a v a 2s . c om * @throws TodParseException */ // todo this parser is horrible public static Date parseIso8061(String s) { try { return DateFormatUtils.ISO_DATE_TIME_ZONE_FORMAT.parse(s); } catch (ParseException ex) { } try { return DateFormatUtils.ISO_DATETIME_FORMAT.parse(s); } catch (ParseException ex) { } try { return DateFormatUtils.ISO_DATE_TIME_ZONE_FORMAT.parse(s); } catch (ParseException ex) { } try { return DateFormatUtils.ISO_DATE_FORMAT.parse(s); } catch (ParseException ex) { } try { return ISO_YEAR_MONTH_FORMAT.parse(s); } catch (ParseException ex) { } try { return ISO_YEAR_FORMAT.parse(s); } catch (ParseException ex) { } // todo week dates, ordinal dates throw new TodParseException("Couldn't parse date as ISO8061. Unparseable date was:" + s); }
From source file:org.gbif.checklistbank.service.mybatis.MultimediaServiceMyBatisIT.java
@Test public void testListByChecklistUsage() { List<NameUsageMediaObject> images = ddt.getService().listByUsage(USAGE_ID, null).getResults(); assertEquals(8, images.size());/*w w w . j av a 2s . c o m*/ for (NameUsageMediaObject m : images) { assertNotNull(m.getIdentifier()); assertNotNull(m.getType()); } NameUsageMediaObject image = images.get(0); // 100010 assertNull(image.getSourceTaxonKey()); assertEquals("2008-01-01", DateFormatUtils.ISO_DATE_FORMAT.format(image.getCreated())); assertEquals("Prashanthns", image.getCreator()); assertEquals("Eurasian Red Squirrel", image.getTitle()); assertEquals("A Eurasian Red Squirrel seen from below. Photographed in Wagenigen, Nederlands.", image.getDescription()); assertEquals(URI.create("http://upload.wikimedia.org/wikipedia/commons/e/e2/Eurasian_Red_Squirrel.jpg"), image.getIdentifier()); assertEquals("Creative Commons Attribution 3.0 Unported", image.getLicense()); assertNull(image.getPublisher()); assertEquals(URI.create("http://en.wikipedia.org/wiki/File:Eurasian_Red_Squirrel.jpg"), image.getReferences()); // TEST PAGING Pageable page = new PagingRequest(0, 1); NameUsageMediaObject d1 = ddt.getService().listByUsage(USAGE_ID, page).getResults().get(0); page = new PagingRequest(1, 1); NameUsageMediaObject d2 = ddt.getService().listByUsage(USAGE_ID, page).getResults().get(0); assertEquals(d1, images.get(0)); assertEquals(d2, images.get(1)); }
From source file:org.gbif.dwca.action.ValidateAction.java
@Override public String execute() { ArchiveLocation archLoc = null;/*w w w.jav a 2 s. c o m*/ try { if (!StringUtils.isBlank(ifModifiedSince)) { ifModifiedSinceDate = DateFormatUtils.ISO_DATE_FORMAT.parse(ifModifiedSince); if (ifModifiedSinceDate == null) { log.debug("Use conditional get for download if modified since: " + ifModifiedSince); return INPUT; } } archLoc = extractArchive(); if (archLoc == null && status == null) { return INPUT; } if (archLoc != null) { extensions = extensionManager.map(); validateAgainstSchema(archLoc.metaFile); validateArchive(archLoc.dwcaFolder); } } catch (ParseException e) { setOffline("Invalid ISO date " + e.getMessage()); } catch (MalformedURLException e) { setOffline("MalformedURLException " + e.getMessage()); } catch (SocketException e) { setOffline(e.getClass().getSimpleName() + " " + e.getMessage()); } catch (Exception e) { log.error("Unknown error when validating archive", e); valid = false; } finally { // cleanup temp files! cleanupTempFile(archLoc); } // store html report if (archLoc != null) { storeReport(); } return SUCCESS; }
From source file:org.kuali.student.repository.viewer.GitGraphDetailsPanel.java
public void setSelectedCommit(RevCommit commit, int inEdges) { inEdgesLabel.setText(String.valueOf(inEdges)); objectIdLabel.setText(commit.getId().name().substring(0, 8)); this.commitMessage.setText(commit.getFullMessage()); this.committer.setText(commit.getCommitterIdent().getName()); this.commitDate.setText(DateFormatUtils.ISO_DATE_FORMAT.format(commit.getCommitterIdent().getWhen())); Transformer<RevCommit, String> transformer = new Transformer<RevCommit, String>() { /* (non-Javadoc) * @see org.apache.commons.collections15.Transformer#transform(java.lang.Object) *//* w w w . j ava 2 s .c o m*/ @Override public String transform(RevCommit input) { RevCommit vertex = input; if (simplify) vertex = RevCommitVertexUtils.findSimplifiedVertex(branchHeadCommitToBranchNameMap, input); String objectIdString = vertex.getId().name().substring(0, 8); return objectIdString; } }; Collection<String> parentIds = CollectionUtils.collect(Arrays.asList(commit.getParents()), transformer); this.parentIdsLabel.setText(StringUtils.join(parentIds, ", ")); String branchName = branchHeadCommitToBranchNameMap.get(commit); if (branchName == null) branchNamePanel.setVisible(false); else { branchNamePanel.setVisible(true); branchNameLabel.setText(branchName); } }
From source file:org.tdwg.dwca.wikipedia.ChecklistBuilder.java
private Dataset buildEml() throws IOException { Dataset dataset = new Dataset(); dataset.setTitle(cfg.getLanguage().getTitleEnglish() + " Wikipedia - Species Pages"); dataset.setLanguage(Language.ENGLISH); dataset.setDataLanguage(cfg.getLanguage()); String description = Resources.toString(Resources.getResource("description.txt"), Charsets.UTF_8); dataset.setDescription(description.replaceAll("$LANGUAGE", cfg.getLanguage().getTitleEnglish()) .replaceAll("$DATE", DateFormatUtils.ISO_DATE_FORMAT.format(modifiedDate))); dataset.setPubDate(modifiedDate);//from w ww .j av a 2 s. c o m dataset.setHomepage(URI.create("http://" + cfg.lang + ".wikipedia.org")); addDeveloper(dataset, ContactType.METADATA_AUTHOR, ContactType.ORIGINATOR, ContactType.ADMINISTRATIVE_POINT_OF_CONTACT); DataDescription d = new DataDescription(); d.setUrl(URI.create(url.toString())); d.setFormat("XML"); d.setName("Wikipedia Article Dump"); dataset.getDataDescriptions().add(d); return dataset; }