Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; import java.util.Locale; public class Main { public static Date getDateTimeNow() { return new Date(getCurrMillis()); } public static long getCurrMillis() { long _t = 0L; try { _t = Calendar.getInstance(Locale.getDefault()).getTimeInMillis(); return _t; } catch (IllegalArgumentException e) { e.printStackTrace(); } _t = new Date().getTime(); return _t; } }