Code example for SimpleDateFormat

Methods: applyPattern, format

0
        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, r.getDisplayMetrics());
    } 
 
    @SuppressLint("SimpleDateFormat") 
	public static String date_string(long time_seconds) {
        SimpleDateFormat sdf = new SimpleDateFormat();
        sdf.applyPattern("MM月d日");
        return sdf.format(new Date(time_seconds * 1000));
    } 
     
    @SuppressLint("SimpleDateFormat") 
	public static String time_string(long time_seconds){
        SimpleDateFormat sdf = new SimpleDateFormat();
        sdf.applyPattern("HH:mm");
        return sdf.format(new Date(time_seconds * 1000));
    } 
     
	@SuppressLint("SimpleDateFormat") 
	public static String friendly_time_string(long time_seconds) {
		Date date = new Date(time_seconds * 1000);
		Date now = new Date();