Tuesday, November 20, 2018

How to convert float to long or int data type in Java?

Yesterday one of the new joiner Java Trainee Engineer from our team came to me and asked about how do you I convert a float variable into long or int data type? He was storing some values coming from another system in the database and only wanted to store value before the decimal point e.g. he was getting "3.144" and he wants to convert it to "3" to store into database. The good thing was that API was returning a float primitive value and you don't need to convert a String to float etc. I asked him whether he needs routing or not, which he wasn't sure but it turns out that he didn't need that. I explained to him how to do that and that's what you will find in this article as well. In short, there are 3 ways to convert a float value into long or int in Java, but we will only focus on long data type part.

Sunday, November 4, 2018

How to Remove Leading/Trailing White Space from a String in SQL Server? LTRIM, RTRIM Example

Unlike Java, Microsoft SQL Server 2008, 2012, 2014,  and even the latest version don't have a built-in trim() function, which can remove both leading and trailing space from the given String. But, SQL Server does have two built-in functions LTRIM() and RTRIM() to remove leading and trailing space. The LTRIM() function removes space from the left side of String so you can use it to get rid of leading space, while RTRIM() removes white-space from the right side of String so you can use it to delete trailing space. You can even combine these two methods to create your own TRIM() method in SQL SERVER e.g. LTRIM(RTRIM(column)) will act as a TRIM() method because it removes both leading and trailing space.

Saturday, November 3, 2018

The Best Course to Learn Spring Security 5 and Spring Data JPA for Java Programmers

If you are a Java Spring developer and working with Spring Security then you may be familiar with the "Learn Spring Security" course by Eugen Paraschiv of Baeldung. It is one of the most advanced and comprehensive courses on Spring Security and the best part of this course is that Eugen always keeps it up-to-date with the new Spring Security release. Now that version Spring Security 5 is out - he has updated his course to use new features of Spring Security 5. Btw, there is some really cool new functionality coming in Spring Security 5 for the reactive programming model, and many other improvements and new features. But, the most important one is the release of OAuth2.