Time elapsed in days, hours, minutes, seconds in Java

Convert a String to an enum in Java
A simple example of how to convert a String to an enum in Java.
Inject Spring context in a Servlet
Sometimes it can be usefull inject the Spring context in a legacy Servlet in order to automatically inject spring beans via @Autowired annotation.
This can be easily done overriding the init method of HttpServlet and putting the statement SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this) in its implementation.
String padding with String.format()

Since 1.5, String.format() can be used to left/right pad a given string. Let’s see how it can be used to do that.
Get all available charsets in java
The following java code can be useful to get all the available charset on the system.

Spring MVC example

The Spring Web model-view-controller (MVC) framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler mappings, view resolution, locale, time zone and theme resolution as well as support for uploading files. The default handler is based on the @Controller and @RequestMapping annotations, offering a wide range of flexible handling methods. With the introduction of Spring 3.0, the @Controller mechanism also allows you to create RESTful Web sites and applications, through the @PathVariable annotation and other features.
How to monitor JMS Queues using JMX

his article describes how to monitor JMS Queue statistics. You can create, collect, analyze, archive, and access diagnostic data generated by a running server and the applications deployed within its containers.
Here there are two very simple JMSX examples which we can use to monitor any JMS resource deployed on our Server. We will focus on JMS queue.

Using SSH keys on your server

An SSH key will let you automatically log into your server from one particular computer without needing to enter your password. This is convenient if you make frequent SSH and scp connections to your server.
You will create an SSH key on your computer, and then configure your server to accept it. This will allow you to automatically log into your server from this computer, without being prompted for your password.

If you want to learn more retro games news, read our magazine and subscribe to our newsletter.