/** * @author lautturi.com * Java example:compute iso 8601 week number in java */ import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.temporal.IsoFields; import java.util.*; public class Lautturi { public static void main(String[] args) { ZoneId zoneId = ZoneId.of ( "America/Montreal" ); ZonedDateTime now = ZonedDateTime.now ( zoneId ); int calendarYear = now.getYear(); int weekYear = now.get ( IsoFields.WEEK_BASED_YEAR ); int weekNumber = now.get ( IsoFields.WEEK_OF_WEEK_BASED_YEAR ); System.out.println(weekNumber); } }Source:www.lautturi.com
output:
47