Example usage for java.util Calendar WEEK_OF_YEAR

List of usage examples for java.util Calendar WEEK_OF_YEAR

Introduction

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

Prototype

int WEEK_OF_YEAR

To view the source code for java.util Calendar WEEK_OF_YEAR.

Click Source Link

Document

Field number for get and set indicating the week number within the current year.

Usage

From source file:com.dc.gameserver.extComponents.Kit.DateUtil.java

public static void main(String args[]) throws ParseException {
    //Date date1 = new Date(playerDailyTaskModel.getCreateTime().getTime());
    Calendar cal1 = Calendar.getInstance();
    Calendar cal2 = Calendar.getInstance();
    cal1.setTime(new Date(Timestamp.valueOf("2012-04-15 20:00:00").getTime()));
    cal2.setTime(new Date(Timestamp.valueOf("2012-04-16 12:00:00").getTime()));
    System.out.println("cal1.WEEK_OF_YEAR=:" + cal1.get(Calendar.WEEK_OF_YEAR));
    System.out.println("cal2.WEEK_OF_YEAR=:" + cal2.get(Calendar.WEEK_OF_YEAR));

}

From source file:Main.java

public static Calendar addWeeks(long time, int days) {
    return add(time, days, Calendar.WEEK_OF_YEAR);
}

From source file:Main.java

public static int getWeekInChina(Calendar calendar) {
    int week = calendar.get(Calendar.WEEK_OF_YEAR);
    int day = calendar.get(Calendar.DAY_OF_WEEK);
    if (day == 1) {
        week = week - 1;/*from  w w  w .  ja  va 2  s.c  om*/
    }
    return week;
}

From source file:Main.java

public static Date lastWeek() {
    return offsiteDate(new Date(), Calendar.WEEK_OF_YEAR, -1);
}

From source file:Main.java

public static int getWeekOfYear() {
    Calendar now = Calendar.getInstance();
    return now.get(Calendar.WEEK_OF_YEAR);
}

From source file:Main.java

public static int getWeek() {
    return getCalendar(getCurrentDate()).get(Calendar.WEEK_OF_YEAR);
}

From source file:Main.java

public static int getWeekOfYear(long timeInMillis) {
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(timeInMillis);// w w w .  j a  v  a2 s  . c  o m
    return cal.get(Calendar.WEEK_OF_YEAR);
}

From source file:Main.java

public static String getSeqWeek() {
    Calendar c = Calendar.getInstance(Locale.CHINA);
    String week = Integer.toString(c.get(Calendar.WEEK_OF_YEAR));
    if (week.length() == 1)
        week = "0" + week;
    String year = Integer.toString(c.get(Calendar.YEAR));
    return year + week;
}

From source file:Main.java

public static int getMonth(int year, int week) {
    Calendar calendar = Calendar.getInstance();
    calendar.clear();/*from www.jav  a 2  s  .  c  om*/
    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.WEEK_OF_YEAR, week);
    return calendar.get(Calendar.MONTH) + 1;
}

From source file:Main.java

public static int getDayOfWeek(int year, int week) {
    Calendar calendar = Calendar.getInstance();
    calendar.clear();//  ww w  .j ava2  s  .co m
    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.WEEK_OF_YEAR, week);
    return calendar.get(Calendar.DAY_OF_MONTH);
}