Java Utililty Methods Year Get

List of utility methods to do Year Get

Description

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

Method

DategetSpecficYearEnd(Date date, int amount)
get Specfic Year End
Date temp = getStartDate(getSpecficYearStart(date, amount + 1));
Calendar cal = Calendar.getInstance();
cal.setTime(temp);
cal.add(Calendar.DAY_OF_YEAR, -1);
return getFinallyDate(cal.getTime());
StringgetStartEndOFWeek(int enterWeek, int enterYear)
Return the date of start and end of the week
Calendar calendar = Calendar.getInstance();
calendar.clear();
calendar.set(Calendar.WEEK_OF_YEAR, enterWeek);
calendar.set(Calendar.YEAR, enterYear);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd"); 
Date startDate = calendar.getTime();
String startDateInStr = formatter.format(startDate);
calendar.add(Calendar.DATE, 6);
...
DategetStartOfYear()
get Start Of Year
return new SimpleDateFormat("dd.MM.yyyy").parse("01.01." + Calendar.getInstance().get(Calendar.YEAR));
intgetThisYear()
Get the current year from a calendar.
return Calendar.getInstance().get(Calendar.YEAR);
StringgetThisYear()
get This Year
String dateString = "";
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy");
java.util.Date currentTime_1 = new java.util.Date();
dateString = formatter.format(currentTime_1);
return dateString;
StringgetThisYear()
get This Year
String dateString = "";
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy");
java.util.Date currentTime_1 = new java.util.Date();
dateString = formatter.format(currentTime_1);
return dateString;
StringgetTwoDigitYear()
get Two Digit Year
int year = new GregorianCalendar().get(Calendar.YEAR) - 2000;
return String.format("%02d", year);
intgetTwoYearsBefore(int date)
get Two Years Before
Calendar calendar = Calendar.getInstance();
int year = Integer.parseInt(String.valueOf(date).substring(0, 4));
int month = Integer.parseInt(String.valueOf(date).substring(4, 6));
int day = Integer.parseInt(String.valueOf(date).substring(6, 8));
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month - 1);
calendar.set(Calendar.DAY_OF_MONTH, day);
calendar.add(Calendar.YEAR, -2);
...
intgetWeekOfYear(Date date)
get Week Of Year
String weekOfYear = format(date, "ww");
return Integer.parseInt(weekOfYear);
String[]getWeekStartEndDate(int timeInfo, String yearInfo)
get Week Start End Date
String[] startEndDate = new String[2];
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.set(Calendar.WEEK_OF_YEAR, timeInfo);
cal.set(Calendar.YEAR, Integer.parseInt(yearInfo));
SimpleDateFormat formatter = new SimpleDateFormat("dd/MMM/yyyy");
cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
startEndDate[0] = formatter.format(cal.getTime());
...