Separate Date and Time objects

前端 未结 2 1046
执念已碎
执念已碎 2021-01-14 08:45

I have a web-form where users can select a date from a calendar pop-up and a time from a dropdown. At the moment I am trying to store the date using a Date object.

2条回答
  •  佛祖请我去吃肉
    2021-01-14 09:16

    Have a look at the Calendar class. It has all of the methods required to get different "date parts". Also, look at the SimpleDateFormat class in java to format the date in needed way.

    Calendar - http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html

    SimpleDateFormat - http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

提交回复
热议问题