Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.TimeZone; public class Main { public static String getTimeStampForDatabase() { Calendar calendar = Calendar.getInstance(TimeZone.getDefault()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss"); simpleDateFormat.setTimeZone(TimeZone.getDefault()); return simpleDateFormat.format(calendar.getTime()); } }