cast date to ms to add long value of duration with criteria

自作多情 提交于 2019-12-11 11:38:55

问题


I have a date and duration. I need to add the duration to date. Date's format is timestamp, duration's - Long (milliseconds). How can I wright criteria to deal this issue? Practically i have something like this: 03-17-2014 21:24:57 + 2523566;


回答1:


If you want to do it in Java and have a java.sql.Date and a long:

public java.sql.Date dateAdd(java.sql.Date inputDate, long duration)
{
    return new java.sql.Date(inputDate.getTime() + duration);
}

A java.sql.Timestamp can be used in place of a java.sql.Date in either the argument or the return value, if required.



来源:https://stackoverflow.com/questions/25303635/cast-date-to-ms-to-add-long-value-of-duration-with-criteria

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!