Simple Date Format in Java

Dates and calendars have long been a challenge for Java programmers. One ray of sunshine in dealing with dates and times has been the SimpleDateFormat class found in the java.text package. The SimpleDateFormat class allows easy conversion of custom formatted Strings to Dates and Dates to custom formatted Strings.

The main use case for the SimpleDateFormat class in real-world is for converting formats between different countries and when processing forms or data. Also, the SimpleDateFormat class is great for formatting times as well as dates.

Continue reading “Simple Date Format in Java”

Commenting Java Code

Comments are essential to good programming. Every file containing code should start with a comment justifying its existence. Comments should be sprinkled liberally throughout every file explaining the purposes and goals of every block of code that is not obvious. When you are in a hurry to finish a task, documenting what you are doing is not glamorous, but years later when you need to go make a fix for yourself or a customer, you’ll be very glad you took the time to comment your code.

Comments are ignored by the ‘javac’ command. The compiler does not care what you put into a comment. You can even put code into a comment and the ‘javac’ command will pretend it doesn’t exist.

Java has three commonly used types of comments. There are the single-line comments, multi-line comments, and Javadoc comments. They are all useful. However, Javadoc comments are the most powerful, because technical documentation for your code can be automatically generated from them.

Continue reading “Commenting Java Code”