/** * 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); }
/** * 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); }
final DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MMM-dd"); final LocalDate dt = dtf.parseLocalDate(yourinput);
DateTimeFormatter f = DateTimeFormat.forPattern("MMMM dd, yyyy"); LocalDate localDate = f.parseLocalDate("January 13, 2012");
@Override public LocalDate parse(String text, Locale locale) throws ParseException { return JodaTimeContextHolder.getFormatter(this.formatter, locale).parseLocalDate(text); }
@Override public LocalDate parse(String text, Locale locale) throws ParseException { return JodaTimeContextHolder.getFormatter(this.formatter, locale).parseLocalDate(text); }
@Override public LocalDate deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { return ISODateTimeFormat.date().parseLocalDate(jsonParser.getValueAsString()); } }
/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * 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); }
@Override protected LocalDate deserialize(String key, DeserializationContext ctxt) throws IOException { return parser.parseLocalDate(key); } }
return DATE_FORMAT.parseLocalDate(dateAsString);
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 } }
/** * 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()); }
/** * 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()); }
return null; LocalDate local = _format.createParser(ctxt).parseLocalDate(str); if (local == null) { return null;
String str = p.getText().trim(); return (str.length() == 0) ? null : _format.createParser(ctxt).parseLocalDate(str); case JsonTokenId.ID_NUMBER_INT:
@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); } } }