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

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

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

ISO8601.format介绍

[英]Formats a Calendar value into an ISO8601-compliant date/time string.
[中]将Calendar值格式化为符合ISO8601标准的日期/时间字符串。

代码示例

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

public String generateRSS(Path indexFile) throws CorruptIndexException,
    IOException {
  StringBuffer output = new StringBuffer();
  output.append(getRSSHeaders());
  IndexSearcher searcher = null;
  try {
    reader = DirectoryReader.open(FSDirectory.open(indexFile));
    searcher = new IndexSearcher(reader);
    GregorianCalendar gc = new java.util.GregorianCalendar(TimeZone.getDefault(), Locale.getDefault());
    gc.setTime(new Date());
    String nowDateTime = ISO8601.format(gc);
    gc.add(java.util.GregorianCalendar.MINUTE, -5);
    String fiveMinsAgo = ISO8601.format(gc);
    TermRangeQuery query = new TermRangeQuery(
        TikaCoreProperties.CREATED.getName(),
        new BytesRef(fiveMinsAgo), new BytesRef(nowDateTime),
        true, true);
    TopScoreDocCollector collector = TopScoreDocCollector.create(20);
    searcher.search(query, collector);
    ScoreDoc[] hits = collector.topDocs().scoreDocs;
    for (int i = 0; i < hits.length; i++) {
      Document doc = searcher.doc(hits[i].doc);
      output.append(getRSSItem(doc));
    }
  } finally {
    if (reader != null) reader.close();
  }
  output.append(getRSSFooters());
  return output.toString();
}

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

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

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

/**
 * Create a new <code>AbstractQValue</code>.
 *
 * @param value
 * @throws IllegalArgumentException if the passed <code>value</code>
 * is <code>null</code>.
 */
protected AbstractQValue(Calendar value) {
  val = ISO8601.format(value);
  type = PropertyType.DATE;
}

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

@Override
  public String toString() {
    return ISO8601.format(this.value);
  }
}

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

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

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

private static String formatTime(long time){
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(time);
    return ISO8601.format(cal);
  }
}

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

private static String formatTime(long time){
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(time);
    return ISO8601.format(cal);
  }
}

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

/**
 * Convert to date. This default implementation delegates to {@link #toCalendar()}
 * and returns the {@code ISO8601.format(Calendar)} value of the calendar.
 * @return  date representation of the converted value
 * @throws IllegalArgumentException  if the string cannot be parsed into a date
 */
public String toDate() {
  return ISO8601.format(toCalendar());
}

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

/**
 * {@inheritDoc}
 */
protected String getInternalString() throws ValueFormatException {
  if (date != null) {
    return ISO8601.format(date);
  } else {
    throw new ValueFormatException("empty value");
  }
}

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

/**
 * {@inheritDoc}
 */
protected String getInternalString() throws ValueFormatException {
  if (date != null) {
    return ISO8601.format(date);
  } else {
    throw new ValueFormatException("empty value");
  }
}

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

/**
 * {@inheritDoc}
 */
protected String getInternalString() throws ValueFormatException {
  if (date != null) {
    return ISO8601.format(date);
  } else {
    throw new ValueFormatException("empty value");
  }
}

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

@Override
  public String toString() {
    return ISO8601.format(this.toCalendar());
  }
}

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

private static void setExpirationTime(@NotNull Tree tree, long time) {
  Calendar calendar = Calendar.getInstance();
  calendar.setTimeInMillis(time);
  tree.setProperty(TOKEN_ATTRIBUTE_EXPIRY, ISO8601.format(calendar), DATE);
}

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

/**
 * Convert to date. This default implementation delegates to {@link #toCalendar()}
 * and returns the {@code ISO8601.format(Calendar)} value of the calendar.
 * @return  date representation of the converted value
 * @throws IllegalArgumentException  if the string cannot be parsed into a date
 */
public String toDate() {
  return ISO8601.format(toCalendar());
}

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

private static void setExpirationTime(@Nonnull Tree tree, long time) {
  Calendar calendar = Calendar.getInstance();
  calendar.setTimeInMillis(time);
  tree.setProperty(TOKEN_ATTRIBUTE_EXPIRY, ISO8601.format(calendar), DATE);
}

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

@Override
public String getString() throws ValueFormatException, IllegalStateException, RepositoryException {
  if (value == null) {
    return "";
  }
  switch (type) {
  case PropertyType.DATE:
    return ISO8601.format((Calendar) value);
  }
  return value.toString();
}

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

private String getUpdatedTime(Calendar currentTime) {
 CommitInfo info = getIndexingContext().getCommitInfo();
 String checkpointTime = (String) info.getInfo().get(IndexConstants.CHECKPOINT_CREATION_TIME);
 if (checkpointTime != null) {
  return checkpointTime;
 }
 return ISO8601.format(currentTime);
}

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

public static PropertyState createDateProperty(@NotNull String name) {
  String now = ISO8601.format(Calendar.getInstance());
  return PropertyStates.createProperty(name, now, DATE);
}

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

public void setDate(String name, long time) {
  Calendar calendar = Calendar.getInstance();
  calendar.setTimeInMillis(time);
  tree.setProperty(name, ISO8601.format(calendar), DATE);
}

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

@Test
  public void dateValueFromDateProperty() throws RepositoryException {
    String expected = ISO8601.format(Calendar.getInstance());
    PropertyState dateProperty = PropertyStates.createProperty(
        "date", expected, Type.DATE);
    String actual = dateProperty.getValue(Type.DATE);
    assertEquals(expected, actual);
  }
}

相关文章