Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java date time

import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;  
public class CurrentDateTimeExample1 {  
  public static void main(String[] args) {  
   DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
   LocalDateTime now = LocalDateTime.now();
   System.out.println(dtf.format(now));
  }  
}  
Comment

java time

import java.time.LocalTime; // import the LocalTime class
...
// To display the current time (hour, minute, second, and nanoseconds)
LocalTime time = LocalTime.now();
System.out.println(time); // 11:04:57.416546
Comment

time in java

import java.util.Calendar;
import java.util.Date;
import java.time.ZonedDateTime;
public class Example {
   public static void main(String[] args) 
   {
      //Getting the current date
      Date date = new Date();
      //This method returns the time in millis
      long timeMilli = date.getTime();
      System.out.println("Time in milliseconds using Date class: " + timeMilli);

      //creating Calendar instance
      Calendar calendar = Calendar.getInstance();
      //Returns current time in millis
      long timeMilli2 = calendar.getTimeInMillis();
      System.out.println("Time in milliseconds using Calendar: " + timeMilli2);
      
      //Java 8 - toEpochMilli() method of ZonedDateTime
      System.out.println("Getting time in milliseconds in Java 8: " + 
      ZonedDateTime.now().toInstant().toEpochMilli());
   }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java map merge example 
Java :: java substring based on delimiter 
Java :: get key from value hashmap 
Java :: How do you count characters in a string array in Java? 
Java :: what is lambda expression in java 
Java :: java search string in string 
Java :: how to turna date into a LocalDateTime java 
Java :: input file in java 
Java :: tostring in java 
Java :: java explicit array declaration 
Java :: Conversion from Java List to Array 
Java :: how to put string in char array in java tutorialspoint 
Java :: how to get request json web token in next js 
Java :: print double without decimal java 
Java :: java vs python 
Java :: how to add textview to listview in android 
Java :: retrofit 
Java :: java string vs stringbuilder 
Java :: how to create an array without knowing the size java 
Java :: settext java 
Java :: how to empty list in java 
Java :: remove empty elements from array java 
Java :: Java path to file 
Java :: how to addin java 
Java :: java rgb to color 
Java :: traversing treemap in java 
Java :: StackAsMyArrayList 
Java :: A* shortest path algorithm 
Java :: alphabet n vowelin java 
Java :: spring yml property boolean 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =