Java Month Day getMonthWeek(String curday)

Here you can find the source of getMonthWeek(String curday)

Description

get Month Week

License

Apache License

Declaration

public static int getMonthWeek(String curday) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {
    static public SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyy-MM-dd");

    public static int getMonthWeek(String curday) {
        try {//from w  ww . j a  v  a2s. c  o  m
            java.util.Date date = str2utilDate(curday);
            Calendar rightNow = Calendar.getInstance();
            rightNow.setTime(date);
            return rightNow.get(Calendar.WEEK_OF_MONTH);
        } catch (Exception e) {
            System.out.println("DateUtil.getYearWeek(str) Error:e = " + e);
            return 0;
        }
    }

    public static java.util.Date str2utilDate(String str) {
        try {
            java.util.Date udate = yyyyMMdd.parse(str);
            return udate;
        } catch (Exception e) {
            System.out.println("DateUtil.str2utilDate(str) Error:e = " + e);
            return null;
        }
    }
}

Related

  1. getMonthLastDay(String curmonth, int month)
  2. getMonthLastDay(String dateString)
  3. getMonthLastDay(String fmt)
  4. getMonthMaxDay(String sDate)
  5. getMonthWeek(String curday)
  6. getPreviosMonthFirstDay()
  7. getShortFirstDayOfMonth()
  8. getStringOfFirstDayInMonth()
  9. getStringOfFirstDayInMonth()