Java Day of Week getWeekth(String sDate)

Here you can find the source of getWeekth(String sDate)

Description

get Weekth

License

Open Source License

Declaration

public static int getWeekth(String sDate) 

Method Source Code

//package com.java2s;
/*//from   w  w  w.  j  a  va 2 s .  c  om
 * @(#)DateUtil.java   1.0  2004/03/15
 *
 * Copyright 2001 - 2004 Bestech, Inc. All rights reserved.
 * This software is the proprietary information of Bestech, Inc.
 * Use is subject to license terms.
 */

import java.util.Calendar;

import java.util.GregorianCalendar;
import java.util.Locale;

public class Main {

    public static int getWeekth(String sDate) {

        if (sDate == null || sDate.length() != 8)
            return -1;

        Calendar c = Calendar.getInstance(Locale.KOREA);
        c.set(Integer.parseInt(sDate.substring(0, 4)), Integer.parseInt(sDate.substring(4, 6)) - 1,
                Integer.parseInt(sDate.substring(6)));

        GregorianCalendar gc = new GregorianCalendar(Locale.KOREA);
        gc.setTime(c.getTime());

        return c.get(Calendar.WEEK_OF_MONTH);
    }
}

Related

  1. getWeekOfYear(String date)
  2. getWeeksBetweenDate(Date begin, Date end)
  3. getWeekStart(Date date)
  4. getWeekStart(Date date)
  5. getWeekStartDateBeforeCurrent(int weekNum, Date current)
  6. getYearOfWeek(Date date)
  7. incWeek(java.util.Date date, int amount, Locale locale)
  8. isMatchWeek(Date date, int week)
  9. isOnWeekend(Date date)