# How to convert LocalDate to string in Java

By Atta Ur Rehman Shah (https://attacomsian.com/about). Published Dec 30, 2019, updated Oct 14, 2022. Topics: Java.
Canonical URL: https://attacomsian.com/blog/java-format-localdate

> A quick tutorial to learn how to format an instance of LocalDate in Java.

The `LocalDate` class is a part of [Java 8 new date and time API](https://attacomsian.com/blog/java-new-date-time-api#localdate-class) that **represents a date without time** in the ISO-8601 format (`yyyy-MM-dd`). This class doesn't store or represent a time or timezone.

In this article, you'll **learn how to format** an instance of `LocalDate` to a date string in Java 8 and higher. `LocalDate` class provides `format()` method that accepts an instance of `DateTimeFormatter` to format *this* date using the specified format:

```java
public String format(DateTimeFormatter formatter)
```

A `DateTimeFormatter` instance specifies the pattern used to format the date and must not be null. `format()` returns the formatted date string if the specified pattern is valid.

The following example demonstrates how you can get the [current LocalDate instance](https://attacomsian.com/blog/java-get-current-date-time#localdate-class) and then use the `format()` method to convert it into a date string:

```java
// current date
LocalDate now = LocalDate.now();

// format date to string
String dateStr = now.format(DateTimeFormatter.ofPattern("EEEE, MMMM dd, yyyy"));

// print date strings
System.out.println("Current Date (before): " + now);
System.out.println("Formatted Date (after): " + dateStr);
```

The above code snippet will output the following:

```bash
Current Date (before): 2019-12-30
Formatted Date (after): Monday, December 30, 2019
```

You can also [convert a string to LocalDate](https://attacomsian.com/blog/java-convert-string-to-date#convert-string-to-localdate) and then use `format()` method to **change the date string format** as shown below:

```java
// old string format
String oldStr = "12/23/2019";

// parse old string to date
LocalDate date = LocalDate.parse(oldStr, DateTimeFormatter.ofPattern("MM/dd/yyyy"));

// format date to string
String newStr = date.format(DateTimeFormatter.ofPattern("MMMM dd, yyyy"));

// print both strings
System.out.println("Date Format (before): " + oldStr);
System.out.println("Date Format (after): " + newStr);
```

Now the output should look like the below:

```bash
Date Format (before): 12/23/2019
Date Format (after): December 23, 2019
```

Check out [How to format a date to string in Java](https://attacomsian.com/blog/java-date-format-to-string) tutorial for more Java 8 new date and time API formatting and parsing examples.
