Martin
Martin

Reputation: 1

How to show current week?

I'm trying to program an android app that show's the current week_of_the_year but haven't found anything similar to what I want, I've seen the date picker but that doesn't show the week numbers and I've also been on android developer site.

So is there any way to view the current week_of_the_year in a really simple way? If there's anyone who can show me this I'll be greatly appreciated.

Upvotes: 0

Views: 4075

Answers (2)

Bart Vandendriessche
Bart Vandendriessche

Reputation: 1392

The easiest way to do this on Android is probably to use the Time class:

int currentWeek = new Time().getWeekNumber();

Upvotes: 2

Sashi Kolli
Sashi Kolli

Reputation: 751

new GregorianCalendar().get(Calendar.WEEK_OF_YEAR);

This should give you the current week in the current time zone. If you need it for a specific date, there are alternate constructors for GregorianCalendar.

Upvotes: 5

Related Questions