Get the weeknumber from a given date in Java FX

前端 未结 4 906
孤城傲影
孤城傲影 2020-12-11 04:46

I have a javafx.scene.control.DatePicker. I want to extract the (Locale) week number from the selected date. Until now i haven\'t found a solution and i prefer not to write

4条回答
  •  没有蜡笔的小新
    2020-12-11 05:16

    You can also use the DateTimeFormatter, looks easier for me :

    LocalDate date = LocalDate.now();
    DateTimeFormatter dtf = DateTimeFormatter.ofPattern("w");
    int week = Integer.parseInt(date.format(dtf));
    

提交回复
热议问题