Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static boolean judgeCurrTime(String time) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); Date date = new Date(); try { date = sdf.parse(time); long t = date.getTime(); long round = System.currentTimeMillis(); if (t - round > 0) { return true; } else { return false; } } catch (Exception e) { e.printStackTrace(); } return false; } public static boolean judgeCurrTime(long time) { long round = System.currentTimeMillis(); if (time - round > 0) { return true; } else { return false; } } public static String getTime(long timeStamp) { String time = null; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String date = sdf.format(timeStamp * 1000); String[] split = date.split("\\s"); if (split.length > 1) { time = split[1]; } return time; } }