Here you can find the source of getYearLastDay(String dateString)
Parameter | Description |
---|---|
dateString | String value |
public static Date getYearLastDay(String dateString)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { /**/*from ww w . j a va 2 s . com*/ * return the last day of the date's year of specified string value in format: yyyy * * @param dateString * String value * @return Date value */ public static Date getYearLastDay(String dateString) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy"); Date date = null; try { date = simpleDateFormat.parse(dateString); } catch (Exception e) { e.printStackTrace(); } Calendar calendar = Calendar.getInstance(); if (date != null) { calendar.setTime(date); } calendar.add(Calendar.YEAR, 1); calendar.add(Calendar.DATE, -1); return calendar.getTime(); } }