Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.GregorianCalendar; import java.util.TimeZone; public class Main { static private long mCalendarGenMs; static public int getTimestamp() { Calendar calendar = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT")); long millis = calendar.getTimeInMillis(); long stamp = millis - mCalendarGenMs; stamp = (stamp + 500) / 1000; return (int) stamp; } }