The timestamp is converted into a string that represents "How long before"

Source: Internet
Author: User
/*** Convert the timestamp into a string that represents "How long before" * @ Param timestr timestamp * @ return */public static string getstandarddate (string timestr) {stringbuffer sb = new stringbuffer (); long T = long. parselong (timestr); long time = system. currenttimemillis ()-(T * 1000); long mill = (long) math. ceil (Time/1000); // long minute = (long) math before the second. ceil (Time/60/1000 running f); // minutes ago long hour = (long) math. ceil (Time/60/60/1000.0f); // hour long Day = (long) math. ceil (Time/24/60/60/1000 then f); // If (day-1> 0) {sb. append (day + "day");} else if (hour-1> 0) {If (hour> = 24) {sb. append ("1 day");} else {sb. append (hour + "Hour") ;}} else if (minute-1> 0) {If (minute = 60) {sb. append ("1 hour");} else {sb. append (minute + "min") ;}} else if (mill-1> 0) {If (Mill = 60) {sb. append ("1 minute");} else {sb. append (Mill + "seconds") ;}} else {SB. append ("just");} If (! SB. tostring (). Equals ("just") {sb. append ("before");} return sb. tostring ();}


The timestamp is converted into a string that represents "How long before"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.