Separate Date and Time objects

前端 未结 2 1025
执念已碎
执念已碎 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:11

    Try this:

    SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy");
    SimpleDateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");
    
    String dateAsString = dateFormatter.format(date);
    String timeAsString = timeFormatter.format(date);
    

提交回复
热议问题