Java Data Type How to - Format LocalDateTime as ISO_WEEK_DATE format


We would like to know how to format LocalDateTime as ISO_WEEK_DATE format.


/*from www  . j  ava2 s . co  m*/
import java.time.LocalDateTime;
import java.time.Month;
import java.time.format.DateTimeFormatter;

public class Main {
  public static void main(String[] args) {
    // 2014-04-01 10:45
    LocalDateTime dateTime = LocalDateTime.of(2014, Month.APRIL, 1, 10, 45);

    // format as ISO week date (2014-W08-4)
    String asIsoWeekDate = dateTime.format(DateTimeFormatter.ISO_WEEK_DATE);

The code above generates the following result.