Spring get next run time by cron expression

I always use cron expression to execute scheduling task. I want to know when the task will be executed. I use CronSequenceGenerator to calculate the next run time which is a class of Spring Framework. The example code is here.

Spring Boot log4j2 example

It is easy to use log4j2 in spring boot. Create a maven project, structure like following.

Start VirtualBox in background

I installed VirtualBox in my computer and installed CentOS in it. When I need Linux environment I start VirtualBox and use ssh(XShell) to connect it. It's boring to start VirtualBox by click Start menus every time. I write a bat script to run VirtualBox in the background. It seems like this.

Java sort stack using temporary stack

In this page I will show you how to sort a stack by using a temporary stack. The key step of sorting is make sure that push items into temporary stack in order. The code is here.

Java reverse stack using recursion

The key step of reversing stack by using recursion is implementing the method popBottom. If we can pop an item from bottom of stack, then we can reverse a stack with two items.

Java implement queue using two stacks

There are two ways to implement queue by using two stacks. The first way is moving all items to another when push or poll method invoked. Another way is using second stack hold some items, move items when needed.

Linux rename command example

As we all known mv command can help me to rename one file. rename is another command to rename file and files. rename command is very useful for renaming multiple files. For example you have three files like following.

Java stack supports getMin with time complexity O(1)

Question: Design a stack supports all stack operations and an extra function getMin() which can get the min element of the stack. The time complexity of all operations above must be O(1).

Java ForkJoinPool example

ForkJoinPool is used to handle the big task which can split into small tasks. I will show you how to use ForkJoinPool and RecursiveTask in this page. Let's say you want to calculate the sum from 1 to 1,000,000,000. There are two ways to calculate. The first way: calculate directly. The second way: split 1,000,000,000 numbers into different groups and calculate them in different thread then adding their respective results together. ForkJoinPool can help you to use different threads

Intellij IDEA keyboard shortcuts not working

I use Intellij IDEA on Linux Mint. Today I found the shortcut Alt + Insert not working. I guess other program may register the same shortcut(Alt + Insert). I close other programs and retry the shortcut again. It's still not working. I know this shortcut may conflict with the system hotkey.

Java CopyOnWriteArrayList example

It will throw ConcurrentModificationException when multiple threads modify ArrayList. If the elements are not too much, CopyOnWriteArrayList is a good choice. CopyOnWriteArrayList copies elements when add new element. It is not recommend to using it when the elements are too many. (It is expensive to copy too many elements.)

git delete branch

Using git branch -d to delete local branch. Using git push -u origin --delete to delete the remote branch.

git checkout new branch and rename

Using following command to checkout new branch and rename it.

MySQL show current database

Use following SQL to show the database name which you are connecting.

Jackson tutorial

Jackson is a high-performance JSON processor for Java.