Skip to content

Instantly share code, notes, and snippets.

@pramoth
Created October 3, 2018 17:33
Show Gist options
  • Select an option

  • Save pramoth/dc21fb46952c4693640f8fee170e412f to your computer and use it in GitHub Desktop.

Select an option

Save pramoth/dc21fb46952c4693640f8fee170e412f to your computer and use it in GitHub Desktop.
LocalDate expectDate = LocalDate.of(2018,9,10);
DateTimeFormatter dateTimeFormatter = new DateTimeFormatterBuilder()
.append(DateTimeFormatter.ofPattern("[yyyy M d]"))
.append(DateTimeFormatter.ofPattern("[d M yyyy]"))
.append(DateTimeFormatter.ofPattern("[d.M.yyyy]"))
.append(DateTimeFormatter.ofPattern("[d/M/yyyy]"))
.toFormatter();
assertThat(LocalDate.parse("2018 09 10",dateTimeFormatter)).isEqualTo(expectDate);
assertThat(LocalDate.parse("10 9 2018",dateTimeFormatter)).isEqualTo(expectDate);
assertThat(LocalDate.parse("10.09.2018",dateTimeFormatter)).isEqualTo(expectDate);
assertThat(LocalDate.parse("10/9/2018",dateTimeFormatter)).isEqualTo(expectDate);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment