java get current time in seconds
// get current time in java using LocalTime.now() method
import java.time.LocalTime;
public class UsingLocalDate
{
public static void main(String[] args)
{
System.out.println(LocalTime.now());
// hr : min : sec.fimto sec
}
}
4
3
import java.util.Calendar;
Date currentTime = Calendar.getInstance().getTime();
Thank you!
3
0
4
5
LocalDateTime date = LocalDateTime.now();
int seconds = date.toLocalTime().toSecondOfDay();
Thank you!
5
0
Are there any code examples left?
New code examples in category Java