Java Year Day getYearFirstDay(String date)

Here you can find the source of getYearFirstDay(String date)

Description

get Year First Day

License

Apache License

Declaration

public static Date getYearFirstDay(String date) 

Method Source Code

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

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Date getYearFirstDay(String date) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy");
        Date d = null;/* ww  w .ja  v a2 s .c o  m*/
        try {
            d = format.parse(date);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Calendar cal = Calendar.getInstance();
        if (d != null) {
            cal.setTime(d);
        }
        cal.add(Calendar.DAY_OF_YEAR, 0);
        return cal.getTime();
    }
}

Related

  1. getLastDayOfTheYear(int year)
  2. getLastDayOfYear(int year)
  3. getLastDayOfYear(int year)
  4. getTodayYear()
  5. getWeekNumOfYearDay(String strDate)
  6. getYearLastDay(String dateString)
  7. getYearWeek(String curday)
  8. getYearWeek(String curday)
  9. lastDay(Integer year, int month)