Parse string to LocalTime with short German format

Description

The following code shows how to parse string to LocalTime with short German format.

Example


import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Locale;
/*from  w ww  .  j a v a2s. c o  m*/
public class Main {
  public static void main(String... args) {
    DateTimeFormatter germanFormatter =
        DateTimeFormatter
                .ofLocalizedTime(FormatStyle.SHORT)
                .withLocale(Locale.GERMAN);

    LocalTime leetTime = LocalTime.parse("13:37", germanFormatter);
    System.out.println(leetTime);



  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    Example »




Convert
Date
Timezone