Java tutorial
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String getSubscribeTime(long time) { try { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String formatTime = format.format(new Date(time)); Calendar cal = Calendar.getInstance(); int year = cal.get(Calendar.YEAR); if (formatTime.startsWith(String.valueOf(year))) { return formatTime.substring(5); } else { return formatTime; } } catch (Exception e) { return ""; } } }