Java GMT time converted to CST time

Source: Internet
Author: User
Tags cst time

Today, when I got the "last modified" time of windchill, we found that GMT time was obtained, but we used to use CST time.

Initial attempt to set directly to CST time zone, Timezone.gettimezone ("CST"), found 8 hours less than GMT

Beijing Time is East 8 district, later changed to Gmt+8 or gmt+8:00 to get to CST time

    Package
        test;
        import Java.text.SimpleDateFormat;
        import java.util.Date;
        import Java.util.TimeZone;
    Public
        class Test {
    Public
        static void Main (string[] args) {
        System.out.println (New Date ());
        SimpleDateFormat sdf = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");
        //CST (Beijing time) in the East 8 district
        Sdf.settimezone (Timezone.gettimezone ("gmt+8"));
        System.out.println (Sdf.format (New Date ()));
        }
      }

Java GMT time converted to CST time

Related Article

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.