org.apache.jackrabbit.util.ISO8601.parse()方法的使用及代码示例

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

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

ISO8601.parse介绍

[英]Parses an ISO8601-compliant date/time string.
[中]解析符合ISO8601的日期/时间字符串。

代码示例

代码示例来源: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: 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. }

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

  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. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. public Calendar getReleaseTime() {
  2. try {
  3. return ISO8601.parse(this.properties.get("releaseTime"));
  4. } catch (Exception e) {
  5. return null;
  6. }
  7. }

代码示例来源: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: 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: apache/jackrabbit-oak

  1. /**
  2. * Creates a {@code DateVersionSelector} that will select the latest
  3. * version of all those that are older than the given timestamp.
  4. *
  5. * @param timestamp reference timestamp
  6. */
  7. public DateVersionSelector(String timestamp) {
  8. this.timestamp = ISO8601.parse(timestamp).getTimeInMillis();
  9. }

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

  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/oak-remote

  1. private long getDate(String date) {
  2. Calendar calendar = ISO8601.parse(date);
  3. if (calendar == null) {
  4. throw new IllegalStateException("invalid date format");
  5. }
  6. return calendar.getTimeInMillis();
  7. }

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

  1. private static long getDateAsMillis(PropertyState ps) {
  2. if (ps == null) {
  3. return -1;
  4. }
  5. String date = ps.getValue(Type.DATE);
  6. Calendar cal = ISO8601.parse(date);
  7. return cal.getTimeInMillis();
  8. }
  9. }

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

  1. private static long getDateAsMillis(PropertyState ps) {
  2. if (ps == null) {
  3. return -1;
  4. }
  5. String date = ps.getValue(Type.DATE);
  6. Calendar cal = ISO8601.parse(date);
  7. return cal.getTimeInMillis();
  8. }
  9. }

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

  1. @Override
  2. public Calendar toCalendar() {
  3. return ISO8601.parse(toString());
  4. }
  5. @Override

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

  1. private Iterable<Long> readDateValues(PropertyValue value) {
  2. List<Long> result = newArrayList();
  3. for (String string : value.getValue(Type.DATES)) {
  4. result.add(ISO8601.parse(string).getTimeInMillis());
  5. }
  6. return result;
  7. }

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

  1. /**
  2. * @see org.apache.sling.jcr.resource.internal.helper.Converter#toCalendar()
  3. */
  4. public Calendar toCalendar() {
  5. final Calendar c = ISO8601.parse(toString());
  6. if (c == null) {
  7. throw new IllegalArgumentException("Not a date string: " + toString());
  8. }
  9. return c;
  10. }

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

  1. /**
  2. * Convert to date. This default implementation is based on {@code ISO8601.parse(String)}.
  3. * @return date representation of the converted value
  4. * @throws IllegalArgumentException if the string cannot be parsed into a date
  5. */
  6. public Calendar toCalendar() {
  7. Calendar date = ISO8601.parse(toString());
  8. if (date == null) {
  9. throw new IllegalArgumentException("Not a date string: " + toString());
  10. }
  11. return date;
  12. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. @Override
  2. public Calendar getDate() throws ValueFormatException, RepositoryException {
  3. if (value instanceof Calendar) {
  4. return (Calendar) value;
  5. } else if (value instanceof String) {
  6. Calendar cal = org.apache.jackrabbit.util.ISO8601.parse((String) value);
  7. if (cal != null) {
  8. return cal;
  9. }
  10. }
  11. throw new ValueFormatException("Value can't be converted to Calendar: " + value);
  12. }

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

  1. private static void computeLastUpdatedTime(NodeState idxState, LuceneIndexInfo info) {
  2. NodeState status = idxState.getChildNode(IndexDefinition.STATUS_NODE);
  3. if (status.exists()){
  4. PropertyState updatedTime = status.getProperty(IndexDefinition.STATUS_LAST_UPDATED);
  5. if (updatedTime != null) {
  6. info.lastUpdatedTime = ISO8601.parse(updatedTime.getValue(Type.DATE)).getTimeInMillis();
  7. }
  8. }
  9. }

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

  1. private static void computeLastUpdatedTime(NodeState idxState, LuceneIndexInfo info) {
  2. NodeState status = idxState.getChildNode(IndexDefinition.STATUS_NODE);
  3. if (status.exists()){
  4. PropertyState updatedTime = status.getProperty(IndexDefinition.STATUS_LAST_UPDATED);
  5. if (updatedTime != null) {
  6. info.lastUpdatedTime = ISO8601.parse(updatedTime.getValue(Type.DATE)).getTimeInMillis();
  7. }
  8. }
  9. }

代码示例来源:origin: org.apache.jackrabbit/com.springsource.org.apache.jackrabbit.spi.commons

  1. /**
  2. * @see QValue#getCalendar()
  3. */
  4. public Calendar getCalendar() throws RepositoryException {
  5. Calendar cal = ISO8601.parse(getString());
  6. if (cal == null) {
  7. throw new ValueFormatException("not a date string: " + getString());
  8. } else {
  9. return cal;
  10. }
  11. }

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

  1. private static void merge(NodeBuilder parent, PropertyState ours, PropertyState theirs) {
  2. Calendar o = parse(ours.getValue(Type.DATE));
  3. Calendar t = parse(theirs.getValue(Type.DATE));
  4. if (JCR_CREATED.equals(ours.getName())) {
  5. parent.setProperty(ours.getName(), pick(o, t, true));
  6. } else {
  7. parent.setProperty(ours.getName(), pick(o, t, false));
  8. }
  9. }

相关文章