
com.opentext.ia.sip.assembly.velocity.DatesTool Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infoarchive-sdk-velocity Show documentation
Show all versions of infoarchive-sdk-velocity Show documentation
A library for building SIP PDI using the Velocity template engine
/*
* Copyright (c) 2016-2017 by OpenText Corporation. All Rights Reserved.
*/
package com.opentext.ia.sip.assembly.velocity;
import java.util.Calendar;
import java.util.Date;
import javax.annotation.Nullable;
import com.opentext.ia.sdk.support.datetime.Dates;
/**
* Tools for working with dates in Velocity templates.
*/
public class DatesTool {
@Nullable
public String format(Object date) {
return Dates.toIso(toDate(date));
}
@Nullable
private Date toDate(Object obj) {
if (obj == null) {
return null;
}
if (obj instanceof Date) {
return (Date)obj;
}
if (obj instanceof Calendar) {
return ((Calendar)obj).getTime();
}
if (obj instanceof Number) {
Date result = new Date();
result.setTime(((Number)obj).longValue());
return result;
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy