InterviewSolution
Saved Bookmarks
| 1. |
Determine day of week for a given date in Java |
|
Answer» The Calendar.DAY_OF_WEEK constant is used in Java to get the day number of week. The EXAMPLE DISPLAYS the same: import java.util.Calendar; public class Example { public static void main(String[] args) { Calendar c = Calendar.getInstance(); System.out.println(c.getTime().toString()); System.out.println("Day = " + c.get(Calendar.DAY_OF_WEEK)); } }The example displays the day number of the week: Sun Dec 16 21:32:34 UTC 2018 Day = 1 |
|