org.joda.time.format.DateTimeFormatter.parseLocalDate()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(191)

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

DateTimeFormatter.parseLocalDate介绍

[英]Parses only the local date from the given text, returning a new LocalDate.

This will parse the text fully according to the formatter, using the UTC zone. Once parsed, only the local date will be used. This means that any parsed time, time-zone or offset field is completely ignored. It also means that the zone and offset-parsed settings are ignored.
[中]只解析给定文本中的本地日期,返回新的LocalDate。
这将使用UTC区域完全根据格式化程序解析文本。解析后,将仅使用本地日期。这意味着任何解析的时间、时区或偏移量字段都将被完全忽略。这还意味着忽略区域和偏移量解析设置。

代码示例

代码示例来源:origin: joda-time/joda-time

/**
 * Parses a {@code LocalDate} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static LocalDate parse(String str, DateTimeFormatter formatter) {
  return formatter.parseLocalDate(str);
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Parses a {@code LocalDate} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static LocalDate parse(String str, DateTimeFormatter formatter) {
  return formatter.parseLocalDate(str);
}

代码示例来源:origin: stackoverflow.com

final DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MMM-dd");
final LocalDate dt = dtf.parseLocalDate(yourinput);

代码示例来源:origin: stackoverflow.com

DateTimeFormatter f = DateTimeFormat.forPattern("MMMM dd, yyyy");
LocalDate localDate = f.parseLocalDate("January 13, 2012");

代码示例来源:origin: spring-projects/spring-framework

@Override
public LocalDate parse(String text, Locale locale) throws ParseException {
  return JodaTimeContextHolder.getFormatter(this.formatter, locale).parseLocalDate(text);
}

代码示例来源:origin: org.springframework/spring-context

@Override
public LocalDate parse(String text, Locale locale) throws ParseException {
  return JodaTimeContextHolder.getFormatter(this.formatter, locale).parseLocalDate(text);
}

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

@Override public LocalDate deserialize(JsonParser jsonParser,
      DeserializationContext deserializationContext)
      throws IOException, JsonProcessingException {
    return ISODateTimeFormat.date().parseLocalDate(jsonParser.getValueAsString());
  }
}

代码示例来源:origin: joda-time/joda-time

/**
 * Parses a {@code YearMonth} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static YearMonth parse(String str, DateTimeFormatter formatter) {
  LocalDate date = formatter.parseLocalDate(str);
  return new YearMonth(date.getYear(), date.getMonthOfYear());
}

代码示例来源:origin: joda-time/joda-time

/**
 * Parses a {@code MonthDay} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static MonthDay parse(String str, DateTimeFormatter formatter) {
  LocalDate date = formatter.parseLocalDate(str);
  return new MonthDay(date.getMonthOfYear(), date.getDayOfMonth());
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Parses a {@code YearMonth} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static YearMonth parse(String str, DateTimeFormatter formatter) {
  LocalDate date = formatter.parseLocalDate(str);
  return new YearMonth(date.getYear(), date.getMonthOfYear());
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Parses a {@code MonthDay} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static MonthDay parse(String str, DateTimeFormatter formatter) {
  LocalDate date = formatter.parseLocalDate(str);
  return new MonthDay(date.getMonthOfYear(), date.getDayOfMonth());
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Parses a {@code LocalDate} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static LocalDate parse(String str, DateTimeFormatter formatter) {
  return formatter.parseLocalDate(str);
}

代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-joda

@Override
  protected LocalDate deserialize(String key, DeserializationContext ctxt) throws IOException {
    return parser.parseLocalDate(key);
  }
}

代码示例来源:origin: stackoverflow.com

return DATE_FORMAT.parseLocalDate(dateAsString);

代码示例来源:origin: stackoverflow.com

import java.util.*;
import org.joda.time.*;
import org.joda.time.format.*;

public class Test {

  public static void main(String[] args) throws Exception {
    DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy")
      .withLocale(Locale.UK);

    LocalDate date = formatter.parseLocalDate("18/08/2012");

    System.out.println(date.getYear());  // 2012
    System.out.println(date.getMonthOfYear()); // 8
    System.out.println(date.getDayOfMonth());   // 18
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Parses a {@code YearMonth} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static YearMonth parse(String str, DateTimeFormatter formatter) {
  LocalDate date = formatter.parseLocalDate(str);
  return new YearMonth(date.getYear(), date.getMonthOfYear());
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Parses a {@code MonthDay} from the specified string using a formatter.
 * 
 * @param str  the string to parse, not null
 * @param formatter  the formatter to use, not null
 * @since 2.0
 */
public static MonthDay parse(String str, DateTimeFormatter formatter) {
  LocalDate date = formatter.parseLocalDate(str);
  return new MonthDay(date.getMonthOfYear(), date.getDayOfMonth());
}

代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-joda

return null;
LocalDate local = _format.createParser(ctxt).parseLocalDate(str);
if (local == null) {
  return null;

代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-joda

String str = p.getText().trim();
  return (str.length() == 0) ? null
      : _format.createParser(ctxt).parseLocalDate(str);
case JsonTokenId.ID_NUMBER_INT:

代码示例来源:origin: kubernetes-client/java

@Override
  public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
    case NULL:
      in.nextNull();
      return null;
    default:
      String date = in.nextString();
      return formatter.parseLocalDate(date);
    }
  }
}

相关文章