Wednesday, July 31, 2019

How do you get the day from Date and Time?

Problem statement:
You are given a date. You just need to write the method, , which returns the day on that date.
For example, if you are given the date August 14th 2017 the method should return MONDAY as the day on that date.
  1. public static String findDay(int mm, int dd, int yy) 
  2. {
  3. java.time.LocalDate dt = java.time.LocalDate.of(yy, mm, dd);
  4. return dt.getDayOfWeek().name();
  5. }
Output: MONDAY

No comments:

Post a Comment

Blueprint for self-improvement

To learn faster: Make the process fun To understand yourself : Write To understand the world better : Read To build deeper connection : Lis...