org.vfdtech.interfaces.IDateTimeUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of utilities-and-generic-tools Show documentation
Show all versions of utilities-and-generic-tools Show documentation
A utilities service with generic tools implementation. Can be
plugged into your java project
package org.vfdtech.interfaces;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.text.DateFormat;
import java.text.ParseException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.Year;
import java.util.Date;
import java.util.List;
import org.vfdtech.exceptions.CustomException;
public interface IDateTimeUtil {
public String convertDateFormat(String fromFormat, String toFormat, String dateToFormat) throws ParseException, NullPointerException, IllegalArgumentException, CustomException;
public String convertDateFormat(String toFormat, Date dateToFormat) throws NullPointerException, IllegalArgumentException, CustomException;
public T getDateFromString(String dateString, Class classToBeConvertedTo);
public T getDateFromString(String dateString, Class classToBeConvertedTo, String formatterString);
public List getDateRange(String startDate, String endDate, boolean includeCurrentDate);
public int getDaysInMonth(LocalDateTime dayInContext);
public LocalDateTime getPreviousDayFrom(LocalDateTime dayInContext);
public LocalDateTime getNextDayFrom(LocalDateTime dayInContext);
public Month getLastMonthFrom(LocalDateTime dayInContext);
public Month getNextMonthFrom(LocalDateTime dayInContext);
/**
* This method returns current day with midnight time
* E.g 2022-01-12 00:00:00
* @return LocalDateTime
*/
public LocalDateTime getTodayMidnight();
/**
* This method returns current month (if month not specified) 's first day with midnight time
* If month is specified, it returns the specified month's first day with midnight time
*
* @param month
* @return
*/
public LocalDateTime getFirstMidnightOfTheMonth(Month... month);
/**
* This method returns current year (if year not specified) 's first day with midnight time
* If year is specified, it returns the specified year's first day with midnight time
*
* @param year
* @return
*/
public LocalDateTime getFirstMidnightOfTheYear(Year... year);
/**
* Add some minutes to current date
*
* @param somMinutes
* @return
* @throws ParseException
*/
public LocalDateTime addMinutesToNowDate(Integer somMinutes) throws ParseException;
/**
* This converts date instance to string
* When format is not passed, this method uses the instantiated date format from the impl class
* @param date
* @param format
* @return
*/
public LocalDateTime convertDateToString(LocalDate date, DateFormat... format);
}