JSON time conversion format (converts the digital time to a visual YYYY-MM-DD HH:MM:SS format)

Source: Internet
Author: User

Reference:

http://blog.csdn.net/u012992462/article/details/47042535

Http://www.cnblogs.com/kissdodog/p/5419923.html

Content:

Usually JSON time is typically in this format.

/date (1436595149269)/

Usually we use Ajax to get down the JSON data, if there is time, is in this format. Among them, the median number "1436595149269" represents the number of milliseconds since January 1, 1970.

This time format is not directly visible to the user because this is a time that humans do not understand. So we need to convert it into a time format that normal people can understand.

1 ImportJava.text.SimpleDateFormat;2 Importjava.util.Date;3 ImportJava.util.TimeZone;4 5 6  Public classTestjsondate {7 8 9     /**Ten * Date converted to JSON will become a series of numbers, how to convert the number to a date One      */ A      Public Static voidMain (string[] args) { -         Longunixstamp=1437646938000l; -Date dt=NewDate (unixstamp); theSimpleDateFormat SDF =NewSimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"); -Sdf.settimezone (Timezone.gettimezone ("Gmt+8")); - System.out.println (Sdf.format (DT)); -     } +  -  +  A}

JSON time conversion format (converts the digital time to a visual YYYY-MM-DD HH:MM:SS format)

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.