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

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

本文整理了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

public String getRSSItem(Document doc) {
  StringBuilder output = new StringBuilder();
  output.append("<item>");
  output.append(emitTag("guid", doc.get(DublinCore.SOURCE.getName()),
      "isPermalink", "true"));
  output.append(emitTag("title", doc.get(TikaCoreProperties.TITLE.getName()), null, null));
  output.append(emitTag("link", doc.get(DublinCore.SOURCE.getName()),
      null, null));
  output.append(emitTag("author", doc.get(TikaCoreProperties.CREATOR.getName()), null, null));
  for (String topic : doc.getValues(TikaCoreProperties.SUBJECT.getName())) {
    output.append(emitTag("category", topic, null, null));
  }
  output.append(emitTag("pubDate", rssDateFormat.format(ISO8601.parse(doc
      .get(TikaCoreProperties.CREATED.getName()))), null, null));
  output.append(emitTag("description", doc.get(TikaCoreProperties.TITLE.getName()), null,
      null));
  output.append("</item>");
  return output.toString();
}

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

/**
 * @param input ISO8601 string representation
 * @return Calendar value or null
 */
public static Calendar calendarFromString(String input) {
  if (input == null) {
    return null;
  }
  return ISO8601.parse(input);
}

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

/**
 * @param input ISO8601 string representation
 * @return Calendar value or null
 */
public static Calendar calendarFromString(String input) {
  if (input == null) {
    return null;
  }
  return ISO8601.parse(input);
}

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

public Calendar getReleaseTime() {
  try {
    return ISO8601.parse(this.properties.get("releaseTime"));
  } catch (Exception e) {
    return null;
  }
}

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

/**
 * Date values are saved with sec resolution
 * @param date jcr data string
 * @return date value in seconds
 */
public static Long dateToLong(String date){
  if( date == null){
    return null;
  }
  //TODO OAK-2204 - Should we change the precision to lower resolution
  return ISO8601.parse(date).getTimeInMillis();
}

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

/**
 * Date values are saved with sec resolution
 * @param date jcr data string
 * @return date value in seconds
 */
public static Long dateToLong(String date){
  if( date == null){
    return null;
  }
  //TODO OAK-2204 - Should we change the precision to lower resolution
  return ISO8601.parse(date).getTimeInMillis();
}

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

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

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

/**
 * Date values are saved with sec resolution
 * @param date jcr data string
 * @return date value in seconds
 */
public static Long dateToLong(String date){
  if( date == null){
    return null;
  }
  //TODO OAK-2204 - Should we change the precision to lower resolution
  return ISO8601.parse(date).getTimeInMillis();
}

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

private long getDate(String date) {
  Calendar calendar = ISO8601.parse(date);
  if (calendar == null) {
    throw new IllegalStateException("invalid date format");
  }
  return calendar.getTimeInMillis();
}

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

private static long getDateAsMillis(PropertyState ps) {
    if (ps == null) {
      return -1;
    }
    String date = ps.getValue(Type.DATE);
    Calendar cal = ISO8601.parse(date);
    return cal.getTimeInMillis();
  }
}

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

private static long getDateAsMillis(PropertyState ps) {
    if (ps == null) {
      return -1;
    }
    String date = ps.getValue(Type.DATE);
    Calendar cal = ISO8601.parse(date);
    return cal.getTimeInMillis();
  }
}

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

@Override
public Calendar toCalendar() {
  return ISO8601.parse(toString());
}
@Override

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

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

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

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

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

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

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

@Override
public Calendar getDate() throws ValueFormatException, RepositoryException {
  if (value instanceof Calendar) {
    return (Calendar) value;
  } else if (value instanceof String) {
    Calendar cal = org.apache.jackrabbit.util.ISO8601.parse((String) value);
    if (cal != null) {
      return cal;
    }
  }
  throw new ValueFormatException("Value can't be converted to Calendar: " + value);
}

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

private static void computeLastUpdatedTime(NodeState idxState, LuceneIndexInfo info) {
  NodeState status = idxState.getChildNode(IndexDefinition.STATUS_NODE);
  if (status.exists()){
    PropertyState updatedTime = status.getProperty(IndexDefinition.STATUS_LAST_UPDATED);
    if (updatedTime != null) {
      info.lastUpdatedTime = ISO8601.parse(updatedTime.getValue(Type.DATE)).getTimeInMillis();
    }
  }
}

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

private static void computeLastUpdatedTime(NodeState idxState, LuceneIndexInfo info) {
  NodeState status = idxState.getChildNode(IndexDefinition.STATUS_NODE);
  if (status.exists()){
    PropertyState updatedTime = status.getProperty(IndexDefinition.STATUS_LAST_UPDATED);
    if (updatedTime != null) {
      info.lastUpdatedTime = ISO8601.parse(updatedTime.getValue(Type.DATE)).getTimeInMillis();
    }
  }
}

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

/**
 * @see QValue#getCalendar()
 */
public Calendar getCalendar() throws RepositoryException {
   Calendar cal = ISO8601.parse(getString());
   if (cal == null) {
     throw new ValueFormatException("not a date string: " + getString());
   } else {
     return cal;
   }
}

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

private static void merge(NodeBuilder parent, PropertyState ours, PropertyState theirs) {
  Calendar o = parse(ours.getValue(Type.DATE));
  Calendar t = parse(theirs.getValue(Type.DATE));
  if (JCR_CREATED.equals(ours.getName())) {
    parent.setProperty(ours.getName(), pick(o, t, true));
  } else {
    parent.setProperty(ours.getName(), pick(o, t, false));
  }
}

相关文章