How to get week of the year in gwt

How do I get the week of the year in gwt? I tried to get a week of the year, but I couldn't. Please guide me. I tried using the below code, but it prints the week of the day, not the whole year.

DateTimeFormat format = DateTimeFormat.getFormat("c"); 
String dayOfWeek = format.format(new Date());
E12CommonUtils.printOnConsole("dayOfWeek ="+dayOfWeek);

      

+3


source to share


1 answer


Below you will do what you requested.



Date date = new Date(); 
Date yearStart = new Date(date.getYear(), 0, 0); 

double week = (date.getTime() - yearStart.getTime())/(double)(7 * 24 * 60 * 60 * 1000);
System.out.println((int)Math.ceil(week));

      

0


source







All Articles