Search code examples
javamillisecondslocaltime

Get all milliseconds from LocalTime Java


I need to know how to get LocalTime to milliseconds

    LocalTime  lunchTime = LocalTime.parse("01:00:00",
            DateTimeFormatter.ISO_TIME);

If i am going to execute lunchTime.getMinute() i only get 0 and lunchTime.getHour() i only get 1 as an hour. How to get value in milliseconds?


Solution

  • You can use System.currentTimeMillis(), refer https://currentmillis.com/

    Also, please refer https://stackoverflow.com/a/26637209/1270989 to followup on parsing date in your choice of format.

    Also, if you trying to get local time in your timezone from an application running in different timezone please follow comment https://stackoverflow.com/a/319398/1270989