org.joda.time.LocalDate.toString()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(213)

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

LocalDate.toString介绍

[英]Output the date time in ISO8601 format (yyyy-MM-dd).
[中]以ISO8601格式(yyyy-MM-dd)输出日期时间。

代码示例

代码示例来源: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: opentripplanner/OpenTripPlanner

@Override public void serialize(LocalDate localDate, JsonGenerator jsonGenerator,
      SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
    jsonGenerator.writeString(localDate.toString(ISODateTimeFormat.date()));
  }
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

@Override
protected void parse(String value) throws Throwable {
  if (value == null || value.equalsIgnoreCase("today") || value.isEmpty()) {
    value = new LocalDate().toString(); // eeew
  }
  String[] fields = value.split("-");
  year  = Integer.parseInt(fields[0]);
  month = Integer.parseInt(fields[1]);
  day   = Integer.parseInt(fields[2]);
  checkRangeInclusive(year, 2000, 2100);
  checkRangeInclusive(month, 1, 12);
  checkRangeInclusive(day, 1, daysInMonth[month - 1]);
}

代码示例来源:origin: killbill/killbill

private void insertData(final LocalDate date1, DateTime date2, DateTime date3) throws SQLException {
  final PreparedStatement stmt = connection.prepareStatement("insert into full_of_dates (date1, datetime1, timestamp1) VALUES (?, ?, ?)");
  try {
    // See https://github.com/killbill/killbill-commons/blob/master/jdbi/src/main/java/org/killbill/commons/jdbi/argument/LocalDateArgumentFactory.java
    if (date1 != null) {
      stmt.setString(1, date1.toString());
    }
    // See https://github.com/killbill/killbill-commons/blob/master/jdbi/src/main/java/org/killbill/commons/jdbi/argument/DateTimeArgumentFactory.java
    if (date2 != null) {
      stmt.setTimestamp(2, new Timestamp(date2.toDate().getTime()));
    }
    // We do not use
    stmt.setTimestamp(3, new Timestamp(new DateTime().toDate().getTime()));
    stmt.execute();
  } finally {
    if (stmt != null) {
      stmt.close();
    }
  }
}

代码示例来源:origin: killbill/killbill

@Test(groups = "fast", description = "Verify Mockito setup in GuicyKillbillTestSuite")
  public void testSpy() {
    clock.setDay(new LocalDate("2012-08-01"));
    Assert.assertEquals(clock.getUTCToday().toString(), "2012-08-01");
    Assert.assertEquals(theRealClock.getUTCToday().toString(), "2012-08-01");
    clock.addMonths(1);
    Assert.assertEquals(clock.getUTCToday().toString(), "2012-09-01");
    Assert.assertEquals(theRealClock.getUTCToday().toString(), "2012-09-01");
    clock.addDays(30);
    Assert.assertEquals(clock.getUTCToday().toString(), "2012-10-01");
    Assert.assertEquals(theRealClock.getUTCToday().toString(), "2012-10-01");
  }
}

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

Assert.assertThat(withJoda.getS(), is(withJsr310.getS()));
Assert.assertThat(withJoda.getD().toString(), is(withJsr310.getD().toString()));
Assert.assertThat(withJoda.getT().toString(), is(withJsr310.getT().toString()));
Assert.assertThat(withJoda.getTs().toString(), is(withJsr310.getTs().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>
 * @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: org.marketcetera/core

/**
 * swap trade constructor for exact swap dates
 * 
 * @param baseCCY
 * @param plCCY
 * @param nearTenor
 */	
public Currency(String baseCCY, String plCCY, LocalDate nearTenor, LocalDate farTenor){
  this(baseCCY, plCCY, nearTenor.toString(fixDateFormat),
      farTenor==null ? null : farTenor.toString(fixDateFormat));
}

代码示例来源:origin: pl.edu.icm.sedno/sedno-api

@Override
  public String marshal(LocalDate v) {
    if (v == null) {
      return null;
    } else {
      return v.toString();
    }
  }
}

代码示例来源:origin: com.thesett.jenerator.utils/jenerator_util

/** {@inheritDoc} */
  public void serialize(LocalDate value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
    jgen.writeString(value.toString());
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-invoice

@Override
public String getFormattedInvoiceDate() {
  final LocalDate invoiceDate = invoice.getInvoiceDate();
  if (invoiceDate == null) {
    return "";
  } else {
    return Strings.nullToEmpty(invoiceDate.toString(dateFormatter));
  }
}

代码示例来源:origin: com.github.fosin/cdp-utils

/**
 * getDateOfLastMonth
 *
 * @return a {@link java.lang.String} object.
 */
public String getDateOfLastMonth(){
  LocalDate dt = new LocalDate();
  return dt.minusMonths(1).toString("yyyy-MM-dd");
}

代码示例来源:origin: com.synaptix/SynaptixWidget

@Override
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) {
  pos.setBeginIndex(0);
  pos.setEndIndex(0);
  toAppendTo.append(((LocalDate) obj).toString(dateTimeFormatter));
  return toAppendTo;
}

代码示例来源:origin: de.ck35.metricstore/metricstore-fs

@ManagedAttribute
  public String getDate() {
    return date().toString();
  }
}

代码示例来源:origin: com.ning.billing/killbill-payment

@Override
  public String toString() {
    final StringBuilder sb = new StringBuilder();

    sb.append(phaseName).append(", ");
    sb.append(startDate.toString()).append(", ");
    sb.append(endDate.toString()).append(", ");
    sb.append(amount.toString()).append(", ");
    sb.append("subscriptionId = ").append(subscriptionId == null ? null : subscriptionId.toString()).append(", ");
    sb.append("bundleId = ").append(bundleId == null ? null : bundleId.toString()).append(", ");

    return sb.toString();
  }
}

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

相关文章