Formatting LocalDate in Java : <p>I defined the following format in Java :</p>

<pre><code>//define format of YYYYMMDD
private final DateTimeFormatter dtf = DateTimeFormatter.BASIC_ISO_DATE;
</code></pre>

<p>My application fetches a certain date from the calendar:</p>

<pre><code>LocalDate localDate = fetchDate(); // fetch date in format "yyyy-mm-dd"
</code></pre>

<p>I want to store an additional two dates in format of <code>dtf</code>. The <code>startOfMonth</code> and <code>endOfMonth</code> of the given <code>localDate</code>.</p>

<p>E.g. if <code>localDate</code> is <code>"2019-12-12"</code> I want to create the following two variables - </p>

<pre><code>String startOfMonth = "20191201";
String endOfMonth = "20191231";
</code></pre>

<p>How can I do that?</p>
