Java Code Examples for org.threeten.bp.format.DateTimeFormatter#parse()

The following examples show how to use org.threeten.bp.format.DateTimeFormatter#parse() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OffsetTime.java    From threetenbp with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Obtains an instance of {@code OffsetTime} from a text string using a specific formatter.
 * <p>
 * The text is parsed using the formatter, returning a time.
 *
 * @param text  the text to parse, not null
 * @param formatter  the formatter to use, not null
 * @return the parsed offset time, not null
 * @throws DateTimeParseException if the text cannot be parsed
 */
public static OffsetTime parse(CharSequence text, DateTimeFormatter formatter) {
    Jdk8Methods.requireNonNull(formatter, "formatter");
    return formatter.parse(text, OffsetTime.FROM);
}
 
Example 2
Source File: YearMonth.java    From threetenbp with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Obtains an instance of {@code YearMonth} from a text string using a specific formatter.
 * <p>
 * The text is parsed using the formatter, returning a year-month.
 *
 * @param text  the text to parse, not null
 * @param formatter  the formatter to use, not null
 * @return the parsed year-month, not null
 * @throws DateTimeParseException if the text cannot be parsed
 */
public static YearMonth parse(CharSequence text, DateTimeFormatter formatter) {
    Jdk8Methods.requireNonNull(formatter, "formatter");
    return formatter.parse(text, YearMonth.FROM);
}
 
Example 3
Source File: MonthDay.java    From threetenbp with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Obtains an instance of {@code MonthDay} from a text string using a specific formatter.
 * <p>
 * The text is parsed using the formatter, returning a month-day.
 *
 * @param text  the text to parse, not null
 * @param formatter  the formatter to use, not null
 * @return the parsed month-day, not null
 * @throws DateTimeParseException if the text cannot be parsed
 */
public static MonthDay parse(CharSequence text, DateTimeFormatter formatter) {
    Jdk8Methods.requireNonNull(formatter, "formatter");
    return formatter.parse(text, MonthDay.FROM);
}
 
Example 4
Source File: OffsetDateTime.java    From threetenbp with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Obtains an instance of {@code OffsetDateTime} from a text string using a specific formatter.
 * <p>
 * The text is parsed using the formatter, returning a date-time.
 *
 * @param text  the text to parse, not null
 * @param formatter  the formatter to use, not null
 * @return the parsed offset date-time, not null
 * @throws DateTimeParseException if the text cannot be parsed
 */
public static OffsetDateTime parse(CharSequence text, DateTimeFormatter formatter) {
    Jdk8Methods.requireNonNull(formatter, "formatter");
    return formatter.parse(text, OffsetDateTime.FROM);
}
 
Example 5
Source File: LocalTime.java    From threetenbp with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Obtains an instance of {@code LocalTime} from a text string using a specific formatter.
 * <p>
 * The text is parsed using the formatter, returning a time.
 *
 * @param text  the text to parse, not null
 * @param formatter  the formatter to use, not null
 * @return the parsed local time, not null
 * @throws DateTimeParseException if the text cannot be parsed
 */
public static LocalTime parse(CharSequence text, DateTimeFormatter formatter) {
    Jdk8Methods.requireNonNull(formatter, "formatter");
    return formatter.parse(text, LocalTime.FROM);
}
 
Example 6
Source File: LocalDate.java    From threetenbp with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Obtains an instance of {@code LocalDate} from a text string using a specific formatter.
 * <p>
 * The text is parsed using the formatter, returning a date.
 *
 * @param text  the text to parse, not null
 * @param formatter  the formatter to use, not null
 * @return the parsed local date, not null
 * @throws DateTimeParseException if the text cannot be parsed
 */
public static LocalDate parse(CharSequence text, DateTimeFormatter formatter) {
    Jdk8Methods.requireNonNull(formatter, "formatter");
    return formatter.parse(text, LocalDate.FROM);
}
 
Example 7
Source File: LocalDateTime.java    From threetenbp with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Obtains an instance of {@code LocalDateTime} from a text string using a specific formatter.
 * <p>
 * The text is parsed using the formatter, returning a date-time.
 *
 * @param text  the text to parse, not null
 * @param formatter  the formatter to use, not null
 * @return the parsed local date-time, not null
 * @throws DateTimeParseException if the text cannot be parsed
 */
public static LocalDateTime parse(CharSequence text, DateTimeFormatter formatter) {
    Jdk8Methods.requireNonNull(formatter, "formatter");
    return formatter.parse(text, LocalDateTime.FROM);
}
 
Example 8
Source File: ZonedDateTime.java    From threetenbp with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Obtains an instance of {@code ZonedDateTime} from a text string using a specific formatter.
 * <p>
 * The text is parsed using the formatter, returning a date-time.
 *
 * @param text  the text to parse, not null
 * @param formatter  the formatter to use, not null
 * @return the parsed zoned date-time, not null
 * @throws DateTimeParseException if the text cannot be parsed
 */
public static ZonedDateTime parse(CharSequence text, DateTimeFormatter formatter) {
    Jdk8Methods.requireNonNull(formatter, "formatter");
    return formatter.parse(text, ZonedDateTime.FROM);
}
 
Example 9
Source File: Year.java    From threetenbp with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Obtains an instance of {@code Year} from a text string using a specific formatter.
 * <p>
 * The text is parsed using the formatter, returning a year.
 *
 * @param text  the text to parse, not null
 * @param formatter  the formatter to use, not null
 * @return the parsed year, not null
 * @throws DateTimeParseException if the text cannot be parsed
 */
public static Year parse(CharSequence text, DateTimeFormatter formatter) {
    Jdk8Methods.requireNonNull(formatter, "formatter");
    return formatter.parse(text, Year.FROM);
}