Convert time field H:M into integer field (minutes) in JAVA

后端 未结 5 873
名媛妹妹
名媛妹妹 2021-01-06 14:25

The JTable includes the time field, e.g. \"01:50\". I need to read this value into the integer variable. For this I´d like to convert time into minutes. For instance \"01:50

5条回答
  •  离开以前
    2021-01-06 15:00

    Since java 1.8 the most elegant solution is probably:

    long minutes = ChronoUnit.MINUTES.between(LocalTime.MIDNIGHT, LocalTime.parse("01:50"));

提交回复
热议问题