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

com.github.tomakehurst.wiremock.extension.responsetemplating.helpers.HandlebarsCurrentDateHelper Maven / Gradle / Ivy

There is a newer version: 3.0.1
Show newest version
package com.github.tomakehurst.wiremock.extension.responsetemplating.helpers;

import com.github.jknack.handlebars.Options;

import java.io.IOException;
import java.util.Date;

public class HandlebarsCurrentDateHelper extends HandlebarsHelper {

    @Override
    public Object apply(Date context, Options options) throws IOException {
        String format = options.hash("format", null);
        String offset = options.hash("offset", null);

        Date date = context != null ? context : new Date();

        if (offset != null) {
            date = new DateOffset(offset).shift(date);
        }

        return new RenderableDate(date, format);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy