Example usage for java.util Calendar setWeekDate

List of usage examples for java.util Calendar setWeekDate

Introduction

In this page you can find the example usage for java.util Calendar setWeekDate.

Prototype

public void setWeekDate(int weekYear, int weekOfYear, int dayOfWeek) 

Source Link

Document

Sets the date of this Calendar with the given date specifiers - week year, week of year, and day of week.

Usage

From source file:Test.java

public static void main(String[] args) {
    Locale locale = Locale.getDefault();
    Calendar calendar = Calendar.getInstance();
    calendar.setWeekDate(2012, 16, 3);

    System.out.println(//from w  ww.  j ava  2s.  c  o  m
            DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime()));
    System.out.println("" + locale.getDisplayLanguage());

    Locale.setDefault(Locale.Category.FORMAT, Locale.JAPANESE);
    Locale.setDefault(Locale.Category.DISPLAY, Locale.GERMAN);

    System.out.println(
            DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime()));
    System.out.println("" + locale.getDisplayLanguage());

}

From source file:Main.java

public static void main(String[] args) {

    Calendar now = Calendar.getInstance();
    System.out.println(now.getTime());
    now.setWeekDate(2013, 12, 2);
    System.out.println(now.getTime());
}

From source file:Test.java

public static void main(String[] args) {
    Calendar calendar = Calendar.getInstance();
    calendar.setWeekDate(2012, 16, 3);

    Builder builder = new Builder();
    builder.setLanguage("hy");
    builder.setScript("Latn");
    builder.setRegion("IT");
    builder.setVariant("arevela");

    Locale locale = builder.build();
    Locale.setDefault(locale);//  w w w  .jav  a  2 s .  c  om

    System.out.println(
            DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime()));
    System.out.println("" + locale.getDisplayLanguage());

    builder.setLanguage("zh");
    builder.setScript("Hans");
    builder.setRegion("CN");

    locale = builder.build();
    Locale.setDefault(locale);

    System.out.println(
            DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime()));
    System.out.println("" + locale.getDisplayLanguage());

}

From source file:Test.java

public static void main(String[] args) {
    Calendar calendar = Calendar.getInstance();
    if (calendar.isWeekDateSupported()) {
        System.out.println("Number of weeks in this year: " + calendar.getWeeksInWeekYear());
        System.out.println("Current week number: " + calendar.get(Calendar.WEEK_OF_YEAR));
    }//from w  w w .j  ava 2  s  .com

    calendar.setWeekDate(2012, 16, 3);
    System.out.println(
            DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime()));

}