Here you can find the source of now()
public static String now()
//package com.java2s; /**/*w w w . j a v a2 s .c om*/ * Tern Framework. * * @author fancimage * @Copyright 2010 qiao_xf@163.com Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 */ import java.util.Date; import java.text.SimpleDateFormat; public class Main { public static String now() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dt = sdf.format(new Date()); return dt; } public static String now(String pattern) { SimpleDateFormat sdf = new SimpleDateFormat(pattern); String dt = sdf.format(new Date()); return dt; } }