LocalDate.pare
时间: 2023-10-14 07:09:40 浏览: 128
se() method in Java
The `LocalDate.parse()` method in Java is used to parse a string representation of a date in the ISO-8601 format into a LocalDate object. The ISO-8601 format is in the form of "yyyy-MM-dd", where "yyyy" is the year, "MM" is the month, and "dd" is the day.
Syntax:
```
public static LocalDate parse(CharSequence text)
```
Parameters:
- `text` - a string representation of a date in the ISO-8601 format
Return Value:
- a LocalDate object representing the parsed date
Example:
```java
String dateString = "2021-08-31";
LocalDate date = LocalDate.parse(dateString);
System.out.println(date); // Output: 2021-08-31
```
In the above example, the `parse()` method is used to parse the string "2021-08-31" into a LocalDate object. The `println()` method is then used to print the parsed date.
阅读全文