本文整理了Java中org.joda.time.LocalDateTime.toString()
方法的一些代码示例,展示了LocalDateTime.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.toString()
方法的具体详情如下:
包路径:org.joda.time.LocalDateTime
类名称:LocalDateTime
方法名:toString
[英]Output the date time in ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSS).
[中]以ISO8601格式输出日期时间(yyyy-MM-ddTHH:MM:ss.SSS)。
代码示例来源:origin: joda-time/joda-time
/**
* Output the date using the specified format pattern.
*
* @param pattern the pattern specification, null means use <code>toString</code>
* @see org.joda.time.format.DateTimeFormat
*/
public String toString(String pattern) {
if (pattern == null) {
return toString();
}
return DateTimeFormat.forPattern(pattern).print(this);
}
代码示例来源:origin: JodaOrg/joda-time
/**
* Output the date using the specified format pattern.
*
* @param pattern the pattern specification, null means use <code>toString</code>
* @see org.joda.time.format.DateTimeFormat
*/
public String toString(String pattern) {
if (pattern == null) {
return toString();
}
return DateTimeFormat.forPattern(pattern).print(this);
}
代码示例来源:origin: joda-time/joda-time
/**
* Output the date using the specified format pattern.
*
* @param pattern the pattern specification, null means use <code>toString</code>
* @param locale Locale to use, null means default
* @see org.joda.time.format.DateTimeFormat
*/
public String toString(String pattern, Locale locale) throws IllegalArgumentException {
if (pattern == null) {
return toString();
}
return DateTimeFormat.forPattern(pattern).withLocale(locale).print(this);
}
代码示例来源:origin: JodaOrg/joda-time
/**
* Output the date using the specified format pattern.
*
* @param pattern the pattern specification, null means use <code>toString</code>
* @param locale Locale to use, null means default
* @see org.joda.time.format.DateTimeFormat
*/
public String toString(String pattern, Locale locale) throws IllegalArgumentException {
if (pattern == null) {
return toString();
}
return DateTimeFormat.forPattern(pattern).withLocale(locale).print(this);
}
代码示例来源:origin: apache/incubator-gobblin
private boolean isDatePatternHourly(String datePattern) {
DateTimeFormatter formatter = DateTimeFormat.forPattern(datePattern);
LocalDateTime refDateTime = new LocalDateTime(2017, 01, 01, 10, 0, 0);
String refDateTimeString = refDateTime.toString(formatter);
LocalDateTime refDateTimeAtStartOfDay = refDateTime.withHourOfDay(0);
String refDateTimeStringAtStartOfDay = refDateTimeAtStartOfDay.toString(formatter);
return !refDateTimeString.equals(refDateTimeStringAtStartOfDay);
}
代码示例来源:origin: apache/incubator-gobblin
@Override
protected List<FileStatus> getFilesAtPath(FileSystem fs, Path path, PathFilter fileFilter) throws IOException {
DateTimeFormatter formatter = DateTimeFormat.forPattern(datePattern);
LocalDateTime endDate = currentTime;
LocalDateTime startDate = endDate.minus(this.lookbackPeriod);
DateRangeIterator dateRangeIterator = new DateRangeIterator(startDate, endDate, isPatternHourly);
List<FileStatus> fileStatuses = Lists.newArrayList();
while (dateRangeIterator.hasNext()) {
Path pathWithDateTime = new Path(path, dateRangeIterator.next().toString(formatter));
fileStatuses.addAll(super.getFilesAtPath(fs, pathWithDateTime, fileFilter));
}
return fileStatuses;
}
}
代码示例来源:origin: apache/incubator-gobblin
@Test
public void testIterator() {
LocalDateTime endDate = new LocalDateTime(2017, 1, 1, 0, 0, 0);
LocalDateTime startDate = endDate.minusHours(2);
String datePattern = "HH/yyyy/MM/dd";
DateTimeFormatter format = DateTimeFormat.forPattern(datePattern);
TimeAwareRecursiveCopyableDataset.DateRangeIterator dateRangeIterator =
new TimeAwareRecursiveCopyableDataset.DateRangeIterator(startDate, endDate, true);
LocalDateTime dateTime = dateRangeIterator.next();
Assert.assertEquals(dateTime.toString(format), "22/2016/12/31");
dateTime = dateRangeIterator.next();
Assert.assertEquals(dateTime.toString(format), "23/2016/12/31");
dateTime = dateRangeIterator.next();
Assert.assertEquals(dateTime.toString(format), "00/2017/01/01");
Assert.assertEquals(dateRangeIterator.hasNext(), false);
datePattern = "yyyy/MM/dd";
format = DateTimeFormat.forPattern(datePattern);
startDate = endDate.minusDays(1);
dateRangeIterator = new TimeAwareRecursiveCopyableDataset.DateRangeIterator(startDate, endDate, false);
dateTime = dateRangeIterator.next();
Assert.assertEquals(dateTime.toString(format), "2016/12/31");
dateTime = dateRangeIterator.next();
Assert.assertEquals(dateTime.toString(format), "2017/01/01");
Assert.assertEquals(dateRangeIterator.hasNext(), false);
}
}
代码示例来源:origin: apache/incubator-gobblin
String startDate = endDate.minusHours(i).toString(formatter);
Path subDirPath = new Path(baseDir1, new Path(startDate));
fs.mkdirs(subDirPath);
String startDate = endDate.minusHours(i).toString(formatter);
Path subDirPath = new Path(baseDir1, new Path(startDate));
Path filePath = new Path(subDirPath, i + ".avro");
String startDate = endDate.minusDays(i).toString(formatter);
Path subDirPath = new Path(baseDir2, new Path(startDate));
fs.mkdirs(subDirPath);
代码示例来源:origin: ebean-orm/ebean
@Override
protected String toJsonISO8601(LocalDateTime value) {
return value.toString();
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Output the date using the specified format pattern.
*
* @param pattern the pattern specification, null means use <code>toString</code>
* @see org.joda.time.format.DateTimeFormat
*/
public String toString(String pattern) {
if (pattern == null) {
return toString();
}
return DateTimeFormat.forPattern(pattern).print(this);
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Output the date using the specified format pattern.
*
* @param pattern the pattern specification, null means use <code>toString</code>
* @param locale Locale to use, null means default
* @see org.joda.time.format.DateTimeFormat
*/
public String toString(String pattern, Locale locale) throws IllegalArgumentException {
if (pattern == null) {
return toString();
}
return DateTimeFormat.forPattern(pattern).withLocale(locale).print(this);
}
代码示例来源:origin: io.virtdata/virtdata-lib-realer
/**
* Output the date using the specified format pattern.
*
* @param pattern the pattern specification, null means use <code>toString</code>
* @see org.joda.time.format.DateTimeFormat
*/
public String toString(String pattern) {
if (pattern == null) {
return toString();
}
return DateTimeFormat.forPattern(pattern).print(this);
}
代码示例来源:origin: Nextdoor/bender
/**
* Output the date using the specified format pattern.
*
* @param pattern the pattern specification, null means use <code>toString</code>
* @see org.joda.time.format.DateTimeFormat
*/
public String toString(String pattern) {
if (pattern == null) {
return toString();
}
return DateTimeFormat.forPattern(pattern).print(this);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.joda-time
/**
* Output the date using the specified format pattern.
*
* @param pattern the pattern specification, null means use <code>toString</code>
* @see org.joda.time.format.DateTimeFormat
*/
public String toString(String pattern) {
if (pattern == null) {
return toString();
}
return DateTimeFormat.forPattern(pattern).print(this);
}
代码示例来源:origin: org.joda/com.springsource.org.joda.time
/**
* Output the date using the specified format pattern.
*
* @param pattern the pattern specification, null means use <code>toString</code>
* @see org.joda.time.format.DateTimeFormat
*/
public String toString(String pattern) {
if (pattern == null) {
return toString();
}
return DateTimeFormat.forPattern(pattern).print(this);
}
代码示例来源:origin: org.sonatype.sisu/sisu-odata4j
public static String formatDateTimeForXml(LocalDateTime localDateTime) {
if (localDateTime == null)
return null;
if (localDateTime.getMillisOfSecond() != 0)
return localDateTime.toString(DATETIME_WITH_MILLIS_XML);
else if (localDateTime.getSecondOfMinute() != 0)
return localDateTime.toString(DATETIME_WITH_SECONDS_XML);
else
return localDateTime.toString(DATETIME_XML);
}
代码示例来源:origin: org.jboss.oreva/odata-core
public static String formatDateTimeForXml(LocalDateTime localDateTime) {
if (localDateTime == null)
return null;
if (localDateTime.getMillisOfSecond() != 0)
return localDateTime.toString(DATETIME_WITH_MILLIS_XML);
else if (localDateTime.getSecondOfMinute() != 0)
return localDateTime.toString(DATETIME_WITH_SECONDS_XML);
else
return localDateTime.toString(DATETIME_XML);
}
代码示例来源:origin: org.apache.gobblin/gobblin-data-management
private boolean isDatePatternHourly(String datePattern) {
DateTimeFormatter formatter = DateTimeFormat.forPattern(datePattern);
LocalDateTime refDateTime = new LocalDateTime(2017, 01, 01, 10, 0, 0);
String refDateTimeString = refDateTime.toString(formatter);
LocalDateTime refDateTimeAtStartOfDay = refDateTime.withHourOfDay(0);
String refDateTimeStringAtStartOfDay = refDateTimeAtStartOfDay.toString(formatter);
return !refDateTimeString.equals(refDateTimeStringAtStartOfDay);
}
代码示例来源:origin: com.synaptix/SynaptixWidget
@Override
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) {
pos.setBeginIndex(0);
pos.setEndIndex(0);
toAppendTo.append(((LocalDateTime) obj).toString(dateTimeFormatter));
return toAppendTo;
}
代码示例来源:origin: dremio/dremio-oss
@Test
public void testToChar() throws Exception {
String expectedResults[] = {(new LocalDate(2008, 2, 23)).toString("yyyy-MMM-dd"),
(new LocalTime(12, 20, 30)).toString("HH mm ss"),
(new LocalDateTime(2008, 2, 23, 12, 0, 0)).toString("yyyy MMM dd HH:mm:ss")};
testCommon(expectedResults, "/functions/date/to_char.json", "/test_simple_date.json");
}
内容来源于网络,如有侵权,请联系作者删除!