Skip to content

Get localized name of each day over next seven days using Android Studio

I should make this calendar of the week with different types of orders to be shown numerically depending on the data I receive. Do you have any idea how I could do this? for java code i should use material or native libraries




Example code, not for production use.

.datesUntil( 1 ) )
.map( localDate -> localDate.getDayOfWeek().getDisplayName( TextStyle.FULL , Locale.TAIWAN ) 

(In real work, never call now twice. At the end of the day, you may get two different values.)


Per your Comment, you are asking how to list the next seven days of the week, localized.

Capture the current date. This requires a time zone, as the date varies around the globe by zone.

ZoneId z = ZoneId.of( "Asia/Tokyo" ) ;
LocalDate today = z ) ;

Loop seven days, incrementing the date. Interrogate each date for its day-of-week. Get the localized name of that day.

Locale locale = Locale.CANADA_FRENCH ;
for( int index = 0 ; index < 7 ; index ++ ) 
    LocalDate ld = today.plusDays( index ) ;
    DayOfWeek dow = ld.getDayOfWeek() ;
    String dowName = dow.getDisplayName( TextStyle.FULL_STANDALONE , locale ) ;
    System.out.println ( dowName ) ;

This has been covered many times already on Stack Overflow. Search to learn more.

7 People found this is helpful