Joda-Time, Time without date

浪尽此生 提交于 2019-12-04 22:56:50

There's the LocalTime class for that purpose.

Read more about partials here. E.g.:

LocalTime time = new LocalTime(12, 20);
String formatted = time.toString("HH:mm");

LocalTime - Immutable class representing a time without a date (no time zone)

Check out this

Since JodaTime 2.0, it's also possible to instanciate a time without date like this:

LocalTime time = LocalTime.parse( //
      "12h20", //
       DateTimeFormatter.forPattern("HH'h'mm") //
);

Java 8 now has its own LocalTime class. No need for an external library.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!