-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain_Homeworks.java
More file actions
71 lines (55 loc) · 2.27 KB
/
Copy pathMain_Homeworks.java
File metadata and controls
71 lines (55 loc) · 2.27 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package Homework;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Year;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
public class Main_Homeworks {
public static void main(String[] args){
//Homework UtilityClasses
//Date();
//DateDecomposition();
//SpecificDateReturns();
//CurentTime();
}
//Write a method named displayCurrentTime that prints the current time to the console.
//Expected Output: The current time in the format HH:MM:SS.
public static void CurentTime(){
DateTimeFormatter newFormat = DateTimeFormatter.ofPattern("dd MMMM yyyy HH:mm:ss");
SimpleDateFormat parsedDateTime;
// System.out.println("New format date time: " + parsedDateTime.format(newFormat));
}
//Write a method named createSpecificDate that returns a date object representing 19th August 2025.
//Expected Output: A date object for 2025-8-19.
public static void SpecificDateReturns(){
}
//Write a method named displayDateComponents that accepts a date as an argument and prints its year, month, and day components separately.
//Input: A date in the format YYYY-MM-DD.
//Expected Output:
//makefile
//Copy code
//Year: YYYY
//Month: MM
//Day: DD
public static void DateDecomposition(){
Date date1 = new Date("YYYY-MM-dd");
SimpleDateFormat formatNowYear = new SimpleDateFormat("YYYY");
SimpleDateFormat formatNowMonth = new SimpleDateFormat("MM");
SimpleDateFormat formatNowDay = new SimpleDateFormat("dd");
String currentDay = formatNowDay.format(date1);
String currentMonth = formatNowMonth.format(date1);
String currentYear = formatNowYear.format(date1);
System.out.println("Dte:" + date1);
//inca in incercari
}
//Write a method named displayTodaysDate that, when called, prints the current date to the console.
//Expected Output: Today's date in the format YYYY-MM-DD.
public static void Date(){
SimpleDateFormat formatter = new SimpleDateFormat("YYYY-MM-dd");
Date date = new Date();
System.out.println(formatter.format(date));
}
}