- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx17UserInput.java
More file actions
Latest commit
44 lines (34 loc) · 1.59 KB
/
Copy pathEx17UserInput.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
packageJavaEntry;
importjava.util.Scanner;
importjava.time.LocalDate;
importjava.time.LocalTime;
importjava.time.LocalDateTime;
importjava.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
publicclassEx17UserInput {
publicstaticvoidmain(String[] args){
LocalDatedateObj = LocalDate.now();
LocalTimetimeObj = LocalTime.now();
System.out.println("Date - " + dateObj + ", Time - " + timeObj);
LocalDateTimedateTimeObj = LocalDateTime.now();
System.out.println(dateTimeObj);
DateTimeFormatterformatDateTime = DateTimeFormatter.ofPattern("dd-mm-yyyy hh:mm");
StringformattedDateTime = dateTimeObj.format(formatDateTime);
System.out.println(formattedDateTime);
try(ScanneruserObj = newScanner(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);
};
}
}