Here you can find the source of getSystemTime(String pattern)
public static String getSystemTime(String pattern)
//package com.java2s; /*/*www.j ava 2 s .com*/ * DateUtil.java * Copyright (c) 2014, CODEROAD, All Rights Reserved. * * This software is the confidential and proprietary information of CODEROAD * ("Confidential Information"). You shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement you entered into with * CODEROAD. */ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; public class Main { /** * Gets the system time. * * @return the system time */ public static String getSystemTime(String pattern) { long secs = System.currentTimeMillis(); SimpleDateFormat sdf = new SimpleDateFormat(pattern); Date date = new Date(secs); return sdf.format(date); } /** * Format. * * @param calendar the calendar * @param pattern the pattern * @return the string */ public static String format(Calendar calendar, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); return fmt.print(new DateTime(calendar)); } /** * Format. * * @param date the date * @param pattern the pattern * @return the string */ public static String format(Date date, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); String strDate = fmt.print(new DateTime(date)); return strDate; } }