Calendar, Date, and DateFormat of the Java language form a basic but very important part of the Java standard. Date is a key part of business logic calculation. All developers should be able to calculate future dates, customize the display format of dates, and parse text data into date objects.
The following is a code to introduce the editing and conversion between Date and Calendar in Java.
The specific code is as follows:
/** * Remove the time part in Data*/public static Date removeTime(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); // Get int year = cal.get(Calneder.YEAR); // Set cal.set(Calendar.HOUR_OF_DAY, 0); return cal.getTime(); }Summarize
The above is the editing and conversion between Date and Calendar in Java introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time!