Get current month year date and day

Calendar localCalendar = Calendar.getInstance(TimeZone.getDefault()); Date cTime = localCalendar.getTime(); int cDay = localCalendar.get(Calendar.DATE); int cMonth = localCalendar.get(Calendar.MONTH) + 1; int cYear = localCalendar.get(Calendar.YEAR); int cdayOfWeek = localCalendar.get(Calendar.DAY_OF_WEEK); int cDayOfMonth = localCalendar.get(Calendar.DAY_OF_MONTH); int cDayOfYear = localCalendar.get(Calendar.DAY_OF_YEAR); System.out.println("Current Date and time details in local timezone"); System.out.println("Current Date: " + cTime); System.out.println("Current Day: " + cDay); System.out.println("Current Month: " + cMonth); System.out.println("Current Year: " + cYear); System.out.println("Current Day of Week: " + cDayOfWeek); System.out.println("Current Day of Month: " + cDayOfMonth); System.out.println("Current Day of Year: " + cDayOfYear); //getting time, date, day of week and other details in GMT timezone Calendar gmtCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
Get current month, year, date and day

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.