

North American Central Time uses daylight saving time too, so here too CDT is output. Cuba uses Cuba Daylight Time at this time of year, so CDT is output. So even though Australian Central Standard Time is sometimes abbreviated just CST, Date chose ACST. Time zones that did not work for this include: You also wanted an abbreviation of CST in the printed output. Since you asked your question it has become Saturday 10th in China Standard Time time zone.Īny time zone will work for getting the right Date value, the start of the day in that time zone.
#CURRENT CST CODE#
Running the above code in Asia/Shanghai time zone gave this output: However, the only one that I could persuade the old-fashioned Date class to abbreviate CST was China Standard Time. Original text: There are a lot of time zones referred to as CST and there’s no way I can be sure which one you intended (and i believe that the comments stating that America/New_York is not one of them are correct). In the Coeur CST High-Current Interconnect System, our design. There is no way to persuade Date.toString() to use a different time zone, so the above output only comes through setting the default time zone. It is difficult to have perfect pin-to-socket alignment when mating two rigid PCBs or bus bars. Getting the right Date value and getting the expected printed output are two different things since Date.toString() picks the default time zone of the JVM and uses it for rendering the string to be returned. Running the above code with the default time zone of the JVM set to America/Chicago gave: truncatedTo(ChronoUnit.DAYS) throws away the time part of the ZonedDateTime, usually leaving us with 00:00:00 on the same day in the same time zone. Instant startOfDay = ZonedDateTime.now(ZoneId.systemDefault())ĭate oldfashionedDate = om(startOfDay)
#CURRENT CST UPGRADE#
So I am assuming that you are only converting to Date because you need a Date for some legacy API that you cannot afford to upgrade to java.time just now. You are getting all the functionality that you need from java.time. You are already using java.time, the modern Java date and time API, ( LocalDateTime, LocalTime, ZoneId). My suggestion only differs in the detail (which is where the devil is, according to some).įirst of all you should avoid using the Date class if you can.
