Calendar properties

In this chapter you will learn:

  1. whether date/time interpretation is to be lenient
  2. Get the available locales

Lenient date/time

boolean isLenient() tells whether date/time interpretation is to be lenient.

import java.util.Calendar;
//from   ja  v a 2s .  c  o m
public class Main{
  public static void main(String[] argv){
      System.out.println(Calendar.getInstance().isLenient());
  }
}

The output:

Get the available locales

static Locale[] getAvailableLocales() returns an array of all locales for which the getInstance methods of this class can return localized instances.

The following code displays all locales from Calendar class:

import java.util.Calendar;
import java.util.Locale;
//j a  v  a 2  s. c o  m
public class Main{
  public static void main(String[] argv){
    Locale[] locales = Calendar.getAvailableLocales();
    for(Locale l: locales){
      System.out.println(l.getDisplayCountry());
    }
  }
}

The output:

Next chapter...

What you will learn in the next chapter:

  1. Get to know GregorianCalendar class
  2. A demo to show how to use GregorianCalendar