How to set the date to next Sunday
Here is the code that would set the date to next Sunday The solution is simple. Use the day of the week. And finding next Sunday is then easy as shown above.
Here is the code that would set the date to next Sunday The solution is simple. Use the day of the week. And finding next Sunday is then easy as shown above.
How to set the hour in a date? Here is the example to do so Here is an example of setting a minute in a date Hopefully you have found this useful
If you want to know how many months is the difference between 2 dates. Here is the code for you I think the code is self explanatory. Using ChronoUnit.MONTHS.between() we can find the difference between the dates. Please do note how we use the LocalDate. If you need to handle specific locales, you would have … Read more
Here is piece of the code that will help you with setting the Date to midnight in Java We take the Calender instance and set the time to the user date. After that we set the hour, minute, second and millis to 0. That gives us the Date set to midnight.
The data that comes from various systems into an application should be handled in a way that we have to do minimum of the work for integration with different systems that provide data. Defined a common interface. All the systems that provide data have to provide a database that follows the interface specification. Application should … Read more
May sound like a question asked in some of the entry level interviews. Of course, an enum can have a main method. Here is an example.
I was recently defining an enum with some keys. But the enum needed more than a key. It also needed a configuration parameter that would define if this key has some special feature avaliable. So I defined the enum with a constructor that had 2 inputs, the key and the configuration boolean attribute. Now the … Read more
If you are using some library but want to exclude all the dependencies that this library may bring in with itself. Maven provides an easy way to exclude all the libraries.
Multi module projects in maven are a great thing. But have you ever faced issues with multi module projects. With lots of smaller services and 1 parent for all the services. Some services at any point may need different dependencies or different versions of same dependencies. So it be better have <optional> on dependencies that … Read more