-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx17UserInput.java
More file actions
44 lines (34 loc) · 1.59 KB
/
Ex17UserInput.java
File metadata and controls
44 lines (34 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package JavaEntry;
import java.util.Scanner;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
// Scanner class is used to get user input, and it is found in the java.util package.
// nextBoolean() Reads a boolean value from the user
// nextFloat() Reads a float value from the user
// nextInt() Reads a int value from the user
// nextLine() Reads a String value from the user
public class Ex17UserInput {
public static void main(String[] args){
LocalDate dateObj = LocalDate.now();
LocalTime timeObj = LocalTime.now();
System.out.println("Date - " + dateObj + ", Time - " + timeObj);
LocalDateTime dateTimeObj = LocalDateTime.now();
System.out.println(dateTimeObj);
DateTimeFormatter formatDateTime = DateTimeFormatter.ofPattern("dd-mm-yyyy hh:mm");
String formattedDateTime = dateTimeObj.format(formatDateTime);
System.out.println(formattedDateTime);
try(Scanner userObj = new Scanner(System.in)){
// System.out.println("Enter Your Name");
// String userName = userObj.nextLine();
// System.out.println("Enter your age");
// short userAge = userObj.nextShort();
// System.out.println("Enter your salary");
// float userSalary = userObj.nextFloat();
// System.out.println("User name is " + userName);
// System.out.println("User age is " + userAge);
// System.out.println("User salary is " + userSalary);
};
}
}