the right way test date & time in java

preview_player
Показать описание
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

#amigoscode #java #unittesting

Don't Forget to
===========================================

⭐ 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
===========================================

► Computer and Monitor
===========================================

► Camera Gear
=============================================

► IDE & Tools I use for coding 💻 🎒
===========================================
- ITerm
- VsCode
- GoLand
- IntelliJ Ultimate
- Sublime

P.S
===========================================

❤️ Thanks for watching
Рекомендации по теме
Комментарии
Автор

I spent 2 hours trying to mock LocalDate in my application with no success. This video pointed exactly what I wanted.
A big thanks to you
👍

kaushikmadakasira
Автор

Yes it's always the best way to test time, i learned it in my internship

mrsofiane
Автор

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

abu-dukhan
Автор

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

erickjhormanromero
Автор

Even when he said smash that like button only few people did, this is free golden contents and it costs nothing on your end.

dataslid
Автор

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 😉

Denys.Stoianov
Автор

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

franciscoruiz
Автор

Nelson, I smashed the like button five times.

kelechidivine
Автор

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.

wallysonruan
Автор

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.

dariofulci
Автор

Thank you for your videos!!
Could u make the video about where you need use the certain time class(LocaleDateTime, Instant, Date and etc) ?

МарсельЮсупов-фю
Автор

really good content, i came across this problem today, but now I know how to solve this :D

jokeey
Автор

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()

sangmin
Автор

i have a question : if a java web dev so i should use what idj eclipse vscode or more ?

saumetatnguoikhien
Автор

thanks mate for all your videos, they are very helpful! PS can u pls send some of the heat back to Aus <3

xixReact
Автор

Iam watching your video right now it inspires me please make regular videos pls bro😟😟😟😟

alameenalameen
Автор

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?

helmigandi
Автор

Great video as usual! Would love some Go content as well :)

terrah
Автор

amazing video that teaches me to be better

ЮрийАндрейцев-йз
Автор

great, thanks for showing how to organise

Jumataev