Here you can find the source of getSysdate(String format)
public static String getSysdate(String format)
//package com.java2s; /*// w w w.j ava 2 s . c om * Copyright (C) 2010 Viettel Telecom. All rights reserved. * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { /** * * @return String * @throws Exception if error */ public static String getSysdate() throws Exception { Calendar calendar = Calendar.getInstance(); return convertDateToString(calendar.getTime()); } public static String getSysdate(String format) { String selectTocharSysdate = "select to_char(sysdate,'dd/mm/yyyy hh24:mi:ss') from dual"; long time = System.currentTimeMillis(); java.sql.Date date = new java.sql.Date(time); return convertDateToString(date, format); } /** * * @param date to convert * @return String * @throws Exception if error */ public static String convertDateToString(Date date) throws Exception { SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); if (date == null) { return ""; } try { return dateFormat.format(date); } catch (Exception e) { throw e; } } public static String convertDateToString(Date date, String pattern) { SimpleDateFormat dateFormat = new SimpleDateFormat(pattern); if (date == null) { return ""; } try { return dateFormat.format(date); } catch (Exception e) { e.printStackTrace(); return ""; } } }