Important Utility Methods
Q. How to get last 10 business days(excluding Holidays & weekends) in java?
supporting methods used in this method are available in Q2 below.
Q. How to get the Date of business day(excluding weekends & Holidays) some days after/before today in java ?
A. Given utility methods have been written for past(before) days. We can test it after applying any negative integer value for days parameter in public Date getTargetDate(int id,int days) method.
Similarly positive integer value can be used to get future dates.
Below in the getHolidays() method, we can put all holidays dates.
Q. How to get number of business days(excluding weekends & holidays) between two dates in java ?
A. Given utility methods has two parameters with start Date & end Date in Date format.
If start Date & end Date are in String convert them into Date as below.
Q. How to convert date from one format to another format in java ?
A. We can use below Utility method to get any Date format changed.
Q. How to convert current Date(in String form) in different time zone in java ?
A. We can use below Utility method to get current Date in different time zone. Here we are taking example of converting current Date from IST to PST time zone.
Q. How to convert current Date(in java.util.Date form) in different time zone in java ?
A. We can use below Utility method to get current Date in different time . Here we are taking example of converting current Date from IST to PST time zone. Return type of method will be java.util.Date this time.
Q. How to get date after/before some number of days in java ? How to add or subtract number of days in a particular date to get new date?
A. We can use below Utility method to get required Date after adding or subtracting some number of days. Here we are taking example of addDays() method where we can pass a date & the number of days need to be added or subtracted. Negative value of days parameter will result in past date.
Q. How to get list of case-insensitive Strings ? How to use contains – without case sensitivity?
A. We can have a requirement where we want to check if list contains some particular string or not . In that case we can use this method .
Put all the items of List into a TreeSet as given above and then check.