week-number.net
Programming Languages
- Java
- PHP
- Python
- Shell Script
- Perl
- MySQL
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.
Example
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));
Output:
Week number:8
comments powered by Disqus