
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
How to get the date and time in JShell in Java 9?
JShell is an interactive command-line tool that can allow us to learn, investigate, and explore the Java language and their API. We can type any valid java code into the console and get immediate results without the need to write a verbose class with the main() method.
If we want to get the current date with time in JShell by using the below code snippet.
C:\Users\User>jshell | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro jshell> new Date() $1 ==> Fri Feb 28 11:59:23 IST 2020 jshell>
In the below code snippet, we need to get a date with a number of milliseconds.
jshell> new Date().getTime() $2 ==> 1582871487654 jshell> System.currentTimeMillis() $3 ==> 1582871513421 jshell> new Date(1582871513421L) $4 ==> Fri Feb 28 12:01:53 IST 2020 jshell>
In the below code snippet, we need to get the time.
jshell> java.time.Instant.now() $5 ==> 2020-02-28T07:07:33.941720100Z jshell>
- Related Articles
- How to get JShell documentation in Java 9?
- How to get Java and OS version, vendor details in JShell in Java 9?
- How to get system properties in JShell in Java 9?\n
- How to get the current date and time in Java?
- How to get Time in Milliseconds for the Given date and time in Java?
- How to debug JShell in Java 9?
- How to reset the JShell session in Java 9?
- JShell in Java 9?
- Get Date and Time parts separately in Java
- How to get (format) date and time from mill seconds in Java?
- How to save the current JShell session in Java 9?
- How to get current date/time in milli seconds in Java?
- How to implement the encapsulation concept in JShell in Java 9?
- How to implement the Fibonacci series in JShell in Java 9?
- How to create a class and object in JShell in Java 9?

Advertisements