All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.vfdtech.interfaces.IDateTimeUtil Maven / Gradle / Ivy

Go to download

A utilities service with generic tools implementation. Can be plugged into your java project

There is a newer version: 0.3.5
Show newest version
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);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy