org.apache.jackrabbit.util.ISO8601类的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中org.apache.jackrabbit.util.ISO8601类的一些代码示例,展示了ISO8601类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ISO8601类的具体详情如下:
包路径:org.apache.jackrabbit.util.ISO8601
类名称:ISO8601

ISO8601介绍

[英]The ISO8601 utility class provides helper methods to deal with date/time formatting using a specific ISO8601-compliant format (see ISO 8601).

The currently supported format is:

  1. ±YYYY-MM-DDThh:mm:ss.SSSTZD

where:

  1. ±YYYY = four-digit year with optional sign where values <= 0 are
  2. denoting years BCE and values > 0 are denoting years CE,
  3. e.g. -0001 denotes the year 2 BCE, 0000 denotes the year 1 BCE,
  4. 0001 denotes the year 1 CE, and so on...
  5. MM = two-digit month (01=January, etc.)
  6. DD = two-digit day of month (01 through 31)
  7. hh = two digits of hour (00 through 23) (am/pm NOT allowed)
  8. mm = two digits of minute (00 through 59)
  9. ss = two digits of second (00 through 59)
  10. SSS = three digits of milliseconds (000 through 999)
  11. TZD = time zone designator, Z for Zulu (i.e. UTC) or an offset from UTC
  12. in the form of +hh:mm or -hh:mm

[中]ISO8601实用程序类提供了帮助程序方法,用于使用符合ISO8601的特定格式(请参见ISO 8601)处理日期/时间格式。
当前支持的格式为:

  1. ±YYYY-MM-DDThh:mm:ss.SSSTZD

其中:

  1. ±YYYY = four-digit year with optional sign where values <= 0 are
  2. denoting years BCE and values > 0 are denoting years CE,
  3. e.g. -0001 denotes the year 2 BCE, 0000 denotes the year 1 BCE,
  4. 0001 denotes the year 1 CE, and so on...
  5. MM = two-digit month (01=January, etc.)
  6. DD = two-digit day of month (01 through 31)
  7. hh = two digits of hour (00 through 23) (am/pm NOT allowed)
  8. mm = two digits of minute (00 through 59)
  9. ss = two digits of second (00 through 59)
  10. SSS = three digits of milliseconds (000 through 999)
  11. TZD = time zone designator, Z for Zulu (i.e. UTC) or an offset from UTC
  12. in the form of +hh:mm or -hh:mm

代码示例

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

  1. private static String formatTime(long time){
  2. Calendar cal = Calendar.getInstance();
  3. cal.setTimeInMillis(time);
  4. return ISO8601.format(cal);
  5. }
  6. }

代码示例来源:origin: apache/jackrabbit-oak

  1. /**
  2. * Date values are saved with sec resolution
  3. * @param date jcr data string
  4. * @return date value in seconds
  5. */
  6. public static Long dateToLong(String date){
  7. if( date == null){
  8. return null;
  9. }
  10. //TODO OAK-2204 - Should we change the precision to lower resolution
  11. return ISO8601.parse(date).getTimeInMillis();
  12. }

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr-commons

  1. /**
  2. * Constructs a <code>DateValue</code> object representing a date.
  3. *
  4. * @param date the date this <code>DateValue</code> should represent
  5. * @throws IllegalArgumentException if the given date cannot be represented
  6. * as defined by ISO 8601.
  7. */
  8. public DateValue(Calendar date) throws IllegalArgumentException {
  9. super(TYPE);
  10. this.date = date;
  11. ISO8601.getYear(date);
  12. }

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr-commons

  1. Calendar cal = Calendar.getInstance(tz);
  2. cal.setLenient(false);
  3. cal.set(Calendar.YEAR, year + 1);
  4. cal.set(Calendar.ERA, GregorianCalendar.BC);
  5. } else {
  6. getYear(cal);
  7. } catch (IllegalArgumentException e) {
  8. return null;

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

  1. /**
  2. * Converts individual java objects to JSONObjects using reflection and
  3. * recursion
  4. *
  5. * @param val an untyped Java object to try to convert
  6. * @return {@code val} if not handled, or return a converted JSONObject,
  7. * JSONArray, or String
  8. */
  9. @SuppressWarnings({"unchecked", "squid:S3776"})
  10. protected static Object convertValue(Object val) {
  11. if (val instanceof Calendar) {
  12. return ISO8601.format((Calendar) val);
  13. } else if (val instanceof Date) {
  14. Calendar calendar = Calendar.getInstance();
  15. calendar.setTime((Date) val);
  16. return ISO8601.format(calendar);
  17. }
  18. return val;
  19. }

代码示例来源:origin: apache/jackrabbit-oak

  1. private static String now() {
  2. return ISO8601.format(Calendar.getInstance());
  3. }

代码示例来源:origin: apache/jackrabbit-oak

  1. public static Calendar getVersionHistoryLastModified(NodeState versionHistory) {
  2. Calendar youngest = Calendar.getInstance();
  3. youngest.setTimeInMillis(0);
  4. for (final ChildNodeEntry entry : versionHistory.getChildNodeEntries()) {
  5. final NodeState version = entry.getNodeState();
  6. if (version.hasProperty(JCR_CREATED)) {
  7. final Calendar created = ISO8601.parse(version.getProperty(JCR_CREATED).getValue(Type.DATE));
  8. if (created.after(youngest)) {
  9. youngest = created;
  10. }
  11. }
  12. }
  13. return youngest;
  14. }

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr-commons

  1. appendZeroPaddedInt(buf, getYear(cal), 4);
  2. buf.append('-');
  3. appendZeroPaddedInt(buf, cal.get(Calendar.MONTH) + 1, 2);
  4. buf.append('-');
  5. appendZeroPaddedInt(buf, cal.get(Calendar.DAY_OF_MONTH), 2);
  6. buf.append('T');
  7. appendZeroPaddedInt(buf, cal.get(Calendar.HOUR_OF_DAY), 2);
  8. buf.append(':');
  9. appendZeroPaddedInt(buf, cal.get(Calendar.MINUTE), 2);
  10. buf.append(':');
  11. appendZeroPaddedInt(buf, cal.get(Calendar.SECOND), 2);
  12. buf.append('.');
  13. appendZeroPaddedInt(buf, cal.get(Calendar.MILLISECOND), 3);
  14. int minutes = Math.abs((offset / (60 * 1000)) % 60);
  15. buf.append(offset < 0 ? '-' : '+');
  16. appendZeroPaddedInt(buf, hours, 2);
  17. buf.append(':');
  18. appendZeroPaddedInt(buf, minutes, 2);
  19. } else {
  20. buf.append('Z');

代码示例来源:origin: org.onehippo.cms7/hippo-addon-channel-manager-content-service

  1. @Override
  2. protected FieldValue getFieldValue(final String value) {
  3. if (StringUtils.isBlank(value)) {
  4. return new FieldValue(StringUtils.EMPTY);
  5. }
  6. final Calendar calendar = ISO8601.parse(value);
  7. if (calendar == null || calendar.getTime().equals(PropertyValueProvider.EMPTY_DATE)) {
  8. return new FieldValue(StringUtils.EMPTY);
  9. }
  10. return new FieldValue(value);
  11. }
  12. }

代码示例来源:origin: apache/jackrabbit-oak

  1. /**
  2. * @return {@code false} if persisted lastUpdated time for index is after {@code calendar}. {@code true} otherwise
  3. */
  4. private boolean isIndexUpdatedAfter(Calendar calendar) {
  5. NodeBuilder indexStats = definitionBuilder.child(":status");
  6. PropertyState indexLastUpdatedValue = indexStats.getProperty("lastUpdated");
  7. if (indexLastUpdatedValue != null) {
  8. Calendar indexLastUpdatedTime = ISO8601.parse(indexLastUpdatedValue.getValue(Type.DATE));
  9. return indexLastUpdatedTime.after(calendar);
  10. } else {
  11. return true;
  12. }
  13. }

代码示例来源:origin: apache/tika

  1. public String generateRSS(Path indexFile) throws CorruptIndexException,
  2. IOException {
  3. StringBuffer output = new StringBuffer();
  4. output.append(getRSSHeaders());
  5. IndexSearcher searcher = null;
  6. try {
  7. reader = DirectoryReader.open(FSDirectory.open(indexFile));
  8. searcher = new IndexSearcher(reader);
  9. GregorianCalendar gc = new java.util.GregorianCalendar(TimeZone.getDefault(), Locale.getDefault());
  10. gc.setTime(new Date());
  11. String nowDateTime = ISO8601.format(gc);
  12. gc.add(java.util.GregorianCalendar.MINUTE, -5);
  13. String fiveMinsAgo = ISO8601.format(gc);
  14. TermRangeQuery query = new TermRangeQuery(
  15. TikaCoreProperties.CREATED.getName(),
  16. new BytesRef(fiveMinsAgo), new BytesRef(nowDateTime),
  17. true, true);
  18. TopScoreDocCollector collector = TopScoreDocCollector.create(20);
  19. searcher.search(query, collector);
  20. ScoreDoc[] hits = collector.topDocs().scoreDocs;
  21. for (int i = 0; i < hits.length; i++) {
  22. Document doc = searcher.doc(hits[i].doc);
  23. output.append(getRSSItem(doc));
  24. }
  25. } finally {
  26. if (reader != null) reader.close();
  27. }
  28. output.append(getRSSFooters());
  29. return output.toString();
  30. }

代码示例来源:origin: apache/tika

  1. public String getRSSItem(Document doc) {
  2. StringBuilder output = new StringBuilder();
  3. output.append("<item>");
  4. output.append(emitTag("guid", doc.get(DublinCore.SOURCE.getName()),
  5. "isPermalink", "true"));
  6. output.append(emitTag("title", doc.get(TikaCoreProperties.TITLE.getName()), null, null));
  7. output.append(emitTag("link", doc.get(DublinCore.SOURCE.getName()),
  8. null, null));
  9. output.append(emitTag("author", doc.get(TikaCoreProperties.CREATOR.getName()), null, null));
  10. for (String topic : doc.getValues(TikaCoreProperties.SUBJECT.getName())) {
  11. output.append(emitTag("category", topic, null, null));
  12. }
  13. output.append(emitTag("pubDate", rssDateFormat.format(ISO8601.parse(doc
  14. .get(TikaCoreProperties.CREATED.getName()))), null, null));
  15. output.append(emitTag("description", doc.get(TikaCoreProperties.TITLE.getName()), null,
  16. null));
  17. output.append("</item>");
  18. return output.toString();
  19. }

代码示例来源:origin: apache/jackrabbit

  1. Calendar cal = Calendar.getInstance(tz);
  2. cal.setLenient(false);
  3. cal.set(Calendar.YEAR, year + 1);
  4. cal.set(Calendar.ERA, GregorianCalendar.BC);
  5. } else {
  6. getYear(cal);
  7. } catch (IllegalArgumentException e) {
  8. return null;

代码示例来源:origin: io.wcm.tooling.commons/io.wcm.tooling.commons.content-package-builder

  1. /**
  2. * @return Variables for placeholder replacement in package metadata.
  3. */
  4. public Map<String, Object> getVars() {
  5. Calendar calendar = Calendar.getInstance();
  6. calendar.setTime(created);
  7. Map<String, Object> vars = new HashMap<>();
  8. vars.put(NAME_GROUP, StringUtils.defaultString(group));
  9. vars.put(NAME_NAME, StringUtils.defaultString(name));
  10. vars.put(NAME_DESCRIPTION, StringUtils.defaultString(description));
  11. vars.put(NAME_CREATED, ISO8601.format(calendar));
  12. vars.put(NAME_CREATED_BY, StringUtils.defaultString(createdBy));
  13. vars.put(NAME_VERSION, StringUtils.defaultString(version));
  14. vars.put(NAME_AC_HANDLING, acHandling != null ? acHandling.getMode() : "");
  15. vars.put("path", "/etc/packages/" + group + "/" + name + ".zip");
  16. vars.putAll(additionalProperties);
  17. return ImmutableMap.copyOf(vars);
  18. }

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

  1. private static String now() {
  2. return ISO8601.format(Calendar.getInstance());
  3. }

代码示例来源:origin: org.apache.jackrabbit/oak-upgrade

  1. public static Calendar getVersionHistoryLastModified(NodeState versionHistory) {
  2. Calendar youngest = Calendar.getInstance();
  3. youngest.setTimeInMillis(0);
  4. for (final ChildNodeEntry entry : versionHistory.getChildNodeEntries()) {
  5. final NodeState version = entry.getNodeState();
  6. if (version.hasProperty(JCR_CREATED)) {
  7. final Calendar created = ISO8601.parse(version.getProperty(JCR_CREATED).getValue(Type.DATE));
  8. if (created.after(youngest)) {
  9. youngest = created;
  10. }
  11. }
  12. }
  13. return youngest;
  14. }

代码示例来源:origin: apache/jackrabbit

  1. appendZeroPaddedInt(buf, getYear(cal), 4);
  2. buf.append('-');
  3. appendZeroPaddedInt(buf, cal.get(Calendar.MONTH) + 1, 2);
  4. buf.append('-');
  5. appendZeroPaddedInt(buf, cal.get(Calendar.DAY_OF_MONTH), 2);
  6. buf.append('T');
  7. appendZeroPaddedInt(buf, cal.get(Calendar.HOUR_OF_DAY), 2);
  8. buf.append(':');
  9. appendZeroPaddedInt(buf, cal.get(Calendar.MINUTE), 2);
  10. buf.append(':');
  11. appendZeroPaddedInt(buf, cal.get(Calendar.SECOND), 2);
  12. buf.append('.');
  13. appendZeroPaddedInt(buf, cal.get(Calendar.MILLISECOND), 3);
  14. int minutes = Math.abs((offset / (60 * 1000)) % 60);
  15. buf.append(offset < 0 ? '-' : '+');
  16. appendZeroPaddedInt(buf, hours, 2);
  17. buf.append(':');
  18. appendZeroPaddedInt(buf, minutes, 2);
  19. } else {
  20. buf.append('Z');

代码示例来源:origin: org.apache.jackrabbit/oak-lucene

  1. /**
  2. * @return {@code false} if persisted lastUpdated time for index is after {@code calendar}. {@code true} otherwise
  3. */
  4. private boolean isIndexUpdatedAfter(Calendar calendar) {
  5. NodeBuilder indexStats = definitionBuilder.child(":status");
  6. PropertyState indexLastUpdatedValue = indexStats.getProperty("lastUpdated");
  7. if (indexLastUpdatedValue != null) {
  8. Calendar indexLastUpdatedTime = ISO8601.parse(indexLastUpdatedValue.getValue(Type.DATE));
  9. return indexLastUpdatedTime.after(calendar);
  10. } else {
  11. return true;
  12. }
  13. }

代码示例来源:origin: org.apache.sling/org.apache.sling.api

  1. /**
  2. * @param input Calendar value
  3. * @return ISO8601 string representation or null
  4. */
  5. public static String calendarToString(Calendar input) {
  6. if (input == null) {
  7. return null;
  8. }
  9. return ISO8601.format(input);
  10. }

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.resourceresolver-mock

  1. /**
  2. * @param input ISO8601 string representation
  3. * @return Calendar value or null
  4. */
  5. public static Calendar calendarFromString(String input) {
  6. if (input == null) {
  7. return null;
  8. }
  9. return ISO8601.parse(input);
  10. }

相关文章