- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Calendar;
- import java.util.Date;
- import java.time.format.DateTimeFormatter;
- import java.time.LocalDate;
- import java.time.format.DateTimeParseException;
- public class CalendarTest {
- public static void main(String args[]) {
- Date aDate = null;
- try {
- aDate = new SimpleDateFormat("yyyy-mm-dd").parse("2012-01-15");
- Calendar aCalendar = Calendar.getInstance();
- aCalendar.setTime(aDate);
- System.out.print(aCalendar.get(aCalendar.DAY_OF_MONTH)+"," + aCalendar.get(aCalendar.MONTH));
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
- LocalDate bDate = LocalDate.parse("2012-01-15", formatter);
- System.out.print(" " + bDate.getDayOfMonth()+"," + bDate.getMonthValue());
- } catch (ParseException ex) {System.out.println("ParseException " + ex);
- } catch (DateTimeParseException ex) {System.out.println(" DateTimeParseException " + ex);
- }
- }
- }
[text] fhcghk
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new:
File Description
- fhcghk
- Paste Code
- 23 Mar-2023
- 1.04 Kb
You can Share it:
Latest Code Pastes