I have this method in Java:
private static int ConvertToTimestamp(Date value)
{
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S", Locale.US);
String text = "1970-01-01 00:00:00.0";
LocalDateTime localDateTime = LocalDateTime.parse(text, formatter);
// getTime() returns milliseconds
int seconds = (int) (value.getTime()/1000) - localDateTime.getSecond();
return seconds;
}
It returns the number of seconds between the input parameter and 1/1/1970. Are there any improvements to this or better ways to do it?
value.getTime() / 1000
? \$\endgroup\$