Тёмный

the right way test date & time in java 

Amigoscode
Подписаться 994 тыс.
Просмотров 47 тыс.
50% 1

The practice to test applications that use time is to pass a Clock into any method that requires the current instant and a dependency injection framework is one way to achieve this.
🚀 Thanks to Mailgun for sponsoring this video! Head to
mailgun.com/amigoscode to try Mailgun today.
🚀 Register your interested for bootcamp here: amigoscode.hopp.to/bootcamp-r...
#amigoscode #java #unittesting
Don't Forget to
===========================================
💯 Subscribe to Amigoscode - bit.ly/2HpF5V8
💯 Courses Available for free here - amigoscode.com/courses
💯 Join Private Facebook Group and Discord - amigoscode.com/p/join-community
⭐ Table Of Contents ⭐
===========================================
00:00 - Intro
04:15 - Testing Date and Time
13:21 - Outro
🙊 Here are the goods for all my videos video 🙊
► Recommended Books
===========================================
- Clean Code - amzn.to/2UGDPlX
- HTTP: The Definitive Guide - amzn.to/2JDVi8s
- Clean Architecture - amzn.to/2xOBNXW
► Computer and Monitor
===========================================
- New Apple MacBook Pro - amzn.to/3464Mmn
- Dell 27 INCH Ultrasharp U2719D Monitor - amzn.to/2xM3nW1
- Double Arm Stand Desk Mount - amzn.to/3aYKKfs
- USB C Hub Multiport Adapter - amzn.to/2Jz7NlL
► Camera Gear
=============================================
- Sony ILCE7M3B Full Frame Mirrorless Camera - amzn.to/346QIJn
- Sigma 16 mm F1.4 DC DN - amzn.to/2wbic3Q
- Sigma 33B965 30 mm F1.4 DC DC - amzn.to/39G37Fd
► IDE & Tools I use for coding 💻 🎒
===========================================
- ITerm
- VsCode
- GoLand
- IntelliJ Ultimate
- Sublime
P.S
===========================================
💯 Don't forget to subscribe | bit.ly/2HpF5V8
💯 Join Private Facebook Group and Discord - amigoscode.com/p/join-community
💯 Follow me on Instagram | bit.ly/2TSkA9w
❤️ Thanks for watching

Наука

Опубликовано:

 

22 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 92   
@amigoscode
@amigoscode 2 года назад
🚀 Thanks to Mailgun for sponsoring this video! Head to mailgun.com/amigoscode to try Mailgun today. 🚀 Register your interested for bootcamp here: amigoscode.hopp.to/bootcamp-register-interest
@flyingrecordofficial
@flyingrecordofficial 2 года назад
Great job bro
@ishyo9220
@ishyo9220 2 года назад
East or west ⬅️ Amigos code is the best 🤣
@flyingrecordofficial
@flyingrecordofficial 2 года назад
@@ishyo9220why laughing 😅
@ishyo9220
@ishyo9220 2 года назад
@@flyingrecordofficial that's smile for expressing my feelings on Amigos code...🤟 I love it 😁
@MrUzair-bw3cg
@MrUzair-bw3cg Год назад
Hello Sir! I am big fan of you. Can you build a Master course on spring boot with javafx. Because no one can explain briefly like you
@mrsofiane
@mrsofiane 2 года назад
Yes it's always the best way to test time, i learned it in my internship
@Denys.Stoianov
@Denys.Stoianov 2 года назад
Thank you Mann, very interesting moment, I've seen it before in the code, but newer pay attention to this, now I know why smart devs use 'clock' together with local datetime. Very helpful. Please do more videos like this, together with the test example 😉
@abu-dukhan
@abu-dukhan 2 года назад
Maasha Allah, Nelson, you really are natural. May Allah increase you in knowledge and reward you abundantly. And I personally cannot thank you enough, because you transformed my life as a Java back-end developer, once again, JazaakAllahu Khair
@erickjhormanromero6905
@erickjhormanromero6905 2 года назад
Our Senior Java developer tought us to use LocaltTime.now() method to test but now i learned a new way of doing. i just need to undestand the reason and start using it. Thanks man
@soheilqalamkari2643
@soheilqalamkari2643 2 месяца назад
It was wonderful.Thanks a lot✌
@vietronaldo23w
@vietronaldo23w 2 года назад
great! it's helpful for me . thanks bro
@user-sv3zv9cn9w
@user-sv3zv9cn9w 2 года назад
Thank you for your videos!! Could u make the video about where you need use the certain time class(LocaleDateTime, Instant, Date and etc) ?
@dataslid
@dataslid Год назад
Even when he said smash that like button only few people did, this is free golden contents and it costs nothing on your end.
@franciscoruiz661
@franciscoruiz661 2 года назад
In my opinion, the best and practice way is create an DateProvider interface. Then we will use DI for own services, and in the tests we use mocks for DateProvider interface. For DateProvider implementation we use LocalDateTime api
@svalyavasvalyava9867
@svalyavasvalyava9867 2 года назад
Thank you so much!
@joke4ey431
@joke4ey431 Год назад
really good content, i came across this problem today, but now I know how to solve this :D
@kelechidivine3350
@kelechidivine3350 Год назад
Nelson, I smashed the like button five times.
@Jumataev
@Jumataev Год назад
great , thanks for showing how to organise
@user-fz1nh3mt1c
@user-fz1nh3mt1c 2 года назад
amazing video that teaches me to be better
@mahmudulislam5303
@mahmudulislam5303 2 года назад
Great video as always
@dariofulci6549
@dariofulci6549 Год назад
Thank you for all course. Can't wait for new interesting one. I hope to see a course which replicate system design of twitter, uber, facebook... using java, kafka, rabbitmq ect. This one Microservices and Distributed Systems is amazing.
@xixReact
@xixReact 2 года назад
thanks mate for all your videos, they are very helpful! PS can u pls send some of the heat back to Aus
@rollingdice
@rollingdice 2 года назад
thank u very much!!
@terrah33
@terrah33 2 года назад
Great video as usual! Would love some Go content as well :)
@Another0neTime
@Another0neTime 2 года назад
Totally smahed that like button.
@flyingrecordofficial
@flyingrecordofficial 2 года назад
great job bro
@luizcalazans6415
@luizcalazans6415 2 года назад
Awesome content
@wallysonruan
@wallysonruan Год назад
Suggestion: Try to scroll the screen in a way that the code to be added or removed always stays near the center of the page, that will help people that uses the closed caption to be able to see the code while also reading the captions. When you edit a code that is too close to the bottom of the view-port we can't see it because the captions will be overlaying it.
@hamza_Techy
@hamza_Techy 2 года назад
Great!
@user-oc1ih4ez2c
@user-oc1ih4ez2c Год назад
@Amigoscode What's the progress bar do you use?
@sau2metat4nguoikhien72
@sau2metat4nguoikhien72 2 года назад
i have a question : if a java web dev so i should use what idj eclipse vscode or more ?
@alameenalameen7191
@alameenalameen7191 Год назад
Iam watching your video right now it inspires me please make regular videos pls bro😟😟😟😟
@angelg3642
@angelg3642 2 года назад
Great vid
@hendhasnaoui9419
@hendhasnaoui9419 Год назад
You rock ❤😊
@erickjhormanromero6905
@erickjhormanromero6905 2 года назад
Can i get the link of the java docs where this is mentioned?
@drakezen
@drakezen 2 года назад
Where is the stackoverflow link to the Java data/time description?
@AaronEzekiel752
@AaronEzekiel752 2 года назад
always watching you
@nametsegothakadu4702
@nametsegothakadu4702 Год назад
Can you make a video tutorial on how to setup maven(and the problems that come with not setting up pom.xml correctly) and missing springboot plugins properly using Intellij ?. I have been struggling with errors regarding my plugins and I have surfed so many blogs for solutions but I still can't make my ide properly work without these errors whenever i download my plugins for my projects. Please when u can I'd widely appreciate it
@user-oo9br5wx2u
@user-oo9br5wx2u 2 года назад
Yeah, it's cool stuff, but you can also use MockedStatic to mock LocalDateTime
@Mr.indian.justice.555
@Mr.indian.justice.555 Год назад
Hey @amigos , please try to make video on spring boot with antlr. Thanks ! 💕
@sangmin7648
@sangmin7648 Год назад
I would also advise to use FixedClock implementation of Clock (which is a inner class of Clock) instead of mocking. Less mocking is always better, just call Clock.fixed()
@AviadShiber-taboola
@AviadShiber-taboola Год назад
agree, much better
@ahmadxrizvi
@ahmadxrizvi 2 года назад
Assalamualaikum, Please try to make videos on Android development. I love your videos.
@codertravel99
@codertravel99 Год назад
Hey hi Nelson it as awesome session thankyou to make a great session but can you please make a longer session on Date time because it is a complex concept thankyou again but if possible then please make a longer session specific on date time
@mxaix
@mxaix Год назад
Hi…Salam, do you know if there are any online internship programs available where people can work voluntarily(unpaid)?
@lenigaussgauss2428
@lenigaussgauss2428 Год назад
Funny at starting 🤣
@helmigandi
@helmigandi 2 года назад
I got error "required a bean of type 'java.time.Clock' that could not be found, Consider defining a bean of type 'java.time.Clock' in your configuration." when Inject ("private final Clock clock") in my service but I did not see Configuration Class in the video?
@karamelkhalfouni4015
@karamelkhalfouni4015 2 года назад
I had the same problem. It seems like Spring expects a bean definition for the autowired Clock class. To solve that I added a class where I defined the bean. I looks like this : @Configuration public class ClockConfig { @Bean public Clock clock() { return Clock.systemDefaultZone(); } }
@programmieraufgaben8391
@programmieraufgaben8391 Год назад
nice !
@user-gx8qs3ov1m
@user-gx8qs3ov1m Год назад
Helpline📲📥⬆️ Questions can come in⬆️
@konstantindevelops131
@konstantindevelops131 2 года назад
And were is the SO link for the time instances?
@thekiterunner7082
@thekiterunner7082 2 года назад
Good....
@eugenesmith9940
@eugenesmith9940 Год назад
If token was expired at current date-time why it becomes valid if we add time?
@Vvay7
@Vvay7 Год назад
can you talking about atomicreference
@didiwaytrooo
@didiwaytrooo Год назад
i am your brother from Egypt , slamo alikom my brother . i am big fan fro you and interested very much in your great videos and tutorials .do you have a UDEMY channel for courses bro ?. i am beginner in the field with java . go on allah with you
@wilkyarny3012
@wilkyarny3012 2 года назад
Hi there I smash the button 😂
@ehsansasanian9653
@ehsansasanian9653 Год назад
I guess you also need to configure Clock Bean in your app config. Otherwise you'd get NoSuchBeanDefinitionException
@top10channels31
@top10channels31 Год назад
Hi guys i am working on a project accidentally I deleted my table and schema sequence table both now spring jpa not creating my table getting errors I have used ddl-auto=update Plz help me mysql8
@precious8326
@precious8326 Год назад
the discord doesn't work ; (
@YasinNabi
@YasinNabi Год назад
This is a beautiful video... thumbs up ! subbed and liked .... a fellow creator.,
@pepeclovis6247
@pepeclovis6247 Год назад
hello can i take some classes from you
@scienc3tv
@scienc3tv 2 года назад
We're missing your "A Salaaaamo Alaykom" in the intro... Great video tho, thank you bro.
@adilwise
@adilwise 2 года назад
Hi Nelson, you missed "to" in the title.
@ahmedmk534
@ahmedmk534 2 года назад
How do you show usages conters ?
@cdhagen
@cdhagen 2 года назад
Newest IntelliJ version does this automatically. Search for „inlay hints“ in the preferences to turn on/off. I personally find it distracting and annoying. 😉
@ahmedmk534
@ahmedmk534 2 года назад
@@cdhagen I have the latest version but still dont have them displayed. I think they are useful when working on bugs/tests and debuging :)
@KolomiecSergeyK
@KolomiecSergeyK 2 года назад
Hello, could you please give link to stackoverflow
@amigoscode
@amigoscode 2 года назад
stackoverflow.com/questions/32437550/whats-the-difference-between-instant-and-localdatetime
@Kim-tr5op
@Kim-tr5op 2 года назад
u should put like and subscribe section at the end of the video
@sykexz6793
@sykexz6793 2 года назад
not everybody watches till the end
@Kim-tr5op
@Kim-tr5op 2 года назад
@@sykexz6793 my comment is based on the human psyche :P If u make a good vid and people stay to the end, then u have a much higher chance for people to like and subscribe.
@Az1zdev
@Az1zdev Год назад
Hello guys, who knows Amigos IDE theme name?
@assemkhaled3715
@assemkhaled3715 Год назад
how to destroy jwt token on logout in spring boot
@ishyo9220
@ishyo9220 2 года назад
Hello brother...🤟 How I will be became like you...🤔 I want to be like you man...😄 From where I should start learning advance Java ... I had done my core Java ... Please guide me & others like me who are following you 💡 my brother help us... 😋
@francksgenlecroyant
@francksgenlecroyant 2 года назад
Hey, search for the video which talks about roadmap made by Amigoscode, I'm sure it will help
@Salihmanisali
@Salihmanisali 2 года назад
Please could you provide the GitHub address
@himanshuu_21
@himanshuu_21 2 года назад
1st view
@billybob1620
@billybob1620 5 месяцев назад
Or you can just use a date provider class which is arguably a lot more simple
@8d_songs
@8d_songs 2 года назад
can you tell us about your religion background did you born as a muslim or you converted to islam
@Coding.Practice
@Coding.Practice Год назад
जय श्री राम।
@teddy6326
@teddy6326 Год назад
Can you teach slowly because sometimes you so fast .
@fahrican9708
@fahrican9708 Год назад
This explanation is amazing, I was doing LocalDateTime.now() always wrong
@volodymyr.kushnir
@volodymyr.kushnir 2 года назад
Why adding clock if there is simpler way: private final DateTimeService dateTimeService; usage: dateTimeService.now() public class DateTimeService { public Date now() { return new Date();} // make your own implementation } p.s. also it seems your code exposes too much data out of confirmation token -> encapsulation issue.
@franciscoripoll63
@franciscoripoll63 2 года назад
excelent video. Your setUp method is not necessary, you just have to put the following annotation at the class level: "@ExtendWith(MockitoExtension.class)".
@erickjhormanromero6905
@erickjhormanromero6905 2 года назад
he also needs to create a When call into the method
@franciscoripoll63
@franciscoripoll63 2 года назад
​@@erickjhormanromero6905 yes, then only mock with clock. OpenMocks line and constructor is not necessary over there
Далее
Learn Dependency Injection and Write Better Code
21:52
Просмотров 169 тыс.
ТЕСТИРОВАНИЕ НА JAVA (JUNIT, MOCKITO)
9:14
JAVA DTO Pattern Tutorial | Simplify Your Code
19:12
Просмотров 195 тыс.
Java Streams Tutorial | 2020
19:13
Просмотров 257 тыс.
Java Date and Time Tutorial #33
9:50
Просмотров 58 тыс.
React Testing for Beginners: Start Here!
1:17:14
Просмотров 78 тыс.
the right way to organise your code
17:33
Просмотров 194 тыс.
Learn How to Use Abstract Classes
17:28
Просмотров 67 тыс.
The Problem with Time & Timezones - Computerphile
10:13
Java 21 Is Good?! | Prime Reacts
27:08
Просмотров 222 тыс.
Functional Programming with Java Streams API
50:00
Просмотров 175 тыс.
Choose a phone for your mom
0:20
Просмотров 7 млн
Это Xiaomi Su7 Max 🤯 #xiaomi #su7max
1:01
Просмотров 1,5 млн
КРУТОЙ ТЕЛЕФОН
0:16
Просмотров 6 млн
iPhone socket cleaning #Fixit
0:30
Просмотров 15 млн