" بىلقۇت تورى
جاۋادا ۋاقىت ھىسابلاش (TimeUtil)


import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
* Created by BiQut on 2020/1/20.
*/

public class TimeUtil {
public static String getFormatTime(String time){
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
long diff = 0;
try {
Date publish_date = df.parse(time);
Date now_date = new Date();
diff = now_date.getTime() - publish_date.getTime();
if (diff < 0) {
return "تاشقى پىلانىتتىن كەپتۇ";
} else {
diff /= (1000 * 60);
if (diff <= 60) {
return diff + "مىنۇت بۇرۇن";
}
diff /= 60;
if (diff <= 24) {
return diff + "سائەت بۇرۇن";
}
diff /= 24;
if (diff < 30) {
if (diff == 1) return "تۈنۈگۈن";
return diff + "كۈم بۇرۇن";
}
DateFormat df_date = new SimpleDateFormat("yyyy-MM-dd");
return df_date.format(publish_date);
}
} catch (ParseException e) {
e.printStackTrace();
}
return time;
}
}