Week number in Java
To get the week number for a date in Java, use the Calendar class. It has a constant called WEEK_OF_YEAR to get the calendar week number for a specific date.
Get the current week number and print it.
Calendar calendar = new GregorianCalendar(); Date trialTime = new Date(); calendar.setTime(trialTime); System.out.println("Week number:" + calendar.get(Calendar.WEEK_OF_YEAR));
comments powered by Disqus