import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.format.DateTimeFormatter; public class Main { public static void main(String[] args) { // How to work with DATES & TIMES using Java // (LocalDate, LocalTime, LocalDateTime, UTC timestamp) // Current date LocalDate date = LocalDate.now(); System.out.println(date); // Current time LocalTime time = LocalTime.now(); System.out.println(time); // Current date and time LocalDateTime dateTime = LocalDateTime.now(); System.out.println(dateTime); // UTC timestamp Instant instant = Instant.now(); System.out.println(instant); // Custom format DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss"); String newDateTime = dateTime.format(formatter); System.out.println(newDateTime); // Comparing dates & times LocalDateTime date1 = LocalDateTime.of(2024, 12, 25, 12, 0, 0); // CHRISTMAS LocalDateTime date2 = LocalDateTime.of(2025, 1, 1, 0, 0, 0); // NEW YEARS DAY if(date1.isBefore(date2)){ System.out.println(date1 + " is earlier than " + date2); } else if(date1.isAfter(date2)){ System.out.println(date1 + " is later than " + date2); } else if(date1.isEqual(date2)){ System.out.println(date1 + " is equal to " + date2); } } }
@Sl33pySt3rdustАй бұрын
its facinating that you can do so much with java, read files, make audio players, use dates & time its really underrated
@SmortMenАй бұрын
"Underrated" you say. Hmm, I don't think so.
@Cubic123Ай бұрын
whenever i learn a new language this guy makes it 100x easier istg
@HnxzxvrАй бұрын
Bro I just started learning java(as in I quit) and you make it so easy to make programs! I haven’t watched a single tutorial except yours and I can build simple programs on my own
@loona_simsАй бұрын
Could you do a series of data structure and algorithms tutorial for Python 😢 There aren’t systematic & well explained introduction on KZbin, and I am hoping maybe someday you could fill the gap❤
@donchuan7528Ай бұрын
can you make a assembly language tutorial pls.
@avian83549 күн бұрын
😭💀💀💀
@strain69Ай бұрын
could you please make a course on django
@shady5063Ай бұрын
Can you make a video about CompleatableFuture in java
@Abdullah-j7h5nАй бұрын
Hello Mr Bro Code, I was wondering whether i can use a mp4 converter to download some videos as i am travelling and have no internet. I am currently doing my A-levels and love your content
@KGB223Ай бұрын
Bro next video suggestion - Devops
@arpitamarjeet.Ай бұрын
Bro next time data science Full course please 🙏
@Андрей-с6х7чАй бұрын
May I ask about OpenGL guide? (C++ or Java)
@gustavoksbrАй бұрын
Bro, how can I help you financially?
@dibeshranjandas4278Ай бұрын
bro please continue your react series please please please please please pleaseplease pleaseplease pleaseplease pleaseplease please
@Veikko_010Ай бұрын
December 17 2024
@deadbeat008Ай бұрын
12/19/2024
@riceuu13 күн бұрын
January 19 2025
@gawrysiak100Ай бұрын
I liked the video. I need you to like my comment now