Java Year Get getHalfYearEndDate(Date date)

Here you can find the source of getHalfYearEndDate(Date date)

Description

get Half Year End Date

License

Open Source License

Declaration

public static Date getHalfYearEndDate(Date date) 

Method Source Code


//package com.java2s;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static Date getHalfYearEndDate(Date date) {

        try {/*ww  w  .j  a  va 2 s .co  m*/
            String strDate = "";
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            String format2 = format.format(date);
            String[] split = format2.split("-");
            String year = split[0];
            String month = split[1];
            int parseInt = Integer.parseInt(month);
            if (parseInt <= 6) {
                strDate = year + "-" + "06" + "-" + "30";

            } else {
                strDate = year + "-" + "12" + "-" + "31";
            }
            Date parse = format.parse(strDate);
            return parse;
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }

    }
}

Related

  1. getCurrentYearAsInt()
  2. getCurrYearFirst()
  3. getDateOneYearFromNow()
  4. getDaysFromYearZero(Calendar date)
  5. getFewYearsTime(String date, int year)
  6. getLastDayOfYear(Date date)
  7. getNextYear()
  8. getNextYearFirst()
  9. getNextYearMonthStr()