Java tutorial
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { private static final String TIME_ZONE_PRC = "PRC"; private static final String STAMP_TO_DATE_INT = "yyyyMMdd"; public static int StampToDateInt(long stamp) { int date = 0; Date datetime = null; Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(stamp); datetime = calendar.getTime(); String format = STAMP_TO_DATE_INT; SimpleDateFormat sdf = new SimpleDateFormat(format); sdf.setTimeZone(TimeZone.getTimeZone(TIME_ZONE_PRC)); try { date = Integer.parseInt(sdf.format(datetime)); } catch (Exception e) { e.printStackTrace(); } //Log.i("StampHelper", "date_int:"+date); return date; } }