Java Utililty Methods Year From

List of utility methods to do Year From

Description

The list of methods to do Year From are organized into topic(s).

Method

DategetYearStart(int year)
get Year Start
Calendar c = Calendar.getInstance(GMT_TIME_ZONE);
c.set(Calendar.YEAR, year);
c.set(Calendar.DAY_OF_YEAR, 1);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
...
longgetYearStart(long ts)
get Year Start
Calendar calendar = Calendar.getInstance(gmt);
calendar.setTimeInMillis(ts);
int year = calendar.get(Calendar.YEAR);
calendar.clear();
calendar.set(year, 0, 1);
return calendar.getTimeInMillis();
StringgetYearStartTime()
get Year Start Time
return new GregorianCalendar().get(Calendar.YEAR) + "-01-01 00:00:00";
booleanisInYear(String dateStr, int year)
is In Year
boolean flag = false;
String[][] yearedge = getYearDateStr(year);
SimpleDateFormat frm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
    Date date = frm.parse(dateStr);
    String startTime = yearedge[0][0];
    String endTime = yearedge[0][1];
    Date startDate = frm.parse(startTime);
...
DatesetYears(Date date, int amount)
Sets the years field to a date returning a new object.
return set(date, Calendar.YEAR, amount);
StringtoNowYear(Date date)
to Now Year
String strDate = "";
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy");
strDate = dateFormat.format(date);
return strDate;
StringtoShortW3CDTF(Date d, boolean yearOnly)
to Short WCDTF
SimpleDateFormat format = new SimpleDateFormat(yearOnly ? "yyyy" : "yyyy-MM-dd");
return format.format(d);
Stringyear()
year
return now("yyyy");
intyear(Date date)
year
String year = yearFormat.format(date);
return Integer.valueOf(year);
intyear(long time)
year
final Calendar FINDER = new GregorianCalendar(UTC_TIME_ZONE);
FINDER.setTimeInMillis(time);
return FINDER.get(Calendar.YEAR);