In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of java SimpleDateFormat how to convert local variables, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value, I believe you will have something to gain after reading this java SimpleDateFormat article on how to convert local variables, let's take a look.
Description
1. When SimpleDateFormat is defined as a local variable, each thread monopolizes the SimpleDateFormat target.
2. It is equivalent to changing a multi-thread program into a single-line program, so there is no problem of thread unsafety.
Example
Import java.text.SimpleDateFormat;import java.util.Date;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors; public class SimpleDateFormatExample {public static void main (String [] args) {/ / create thread pool ExecutorService threadPool = Executors.newFixedThreadPool (10); / / execute 10 time formatting for (int I = 0; I < 10; iForm +) {int finalI = I / / Thread pool executes task threadPool.execute (new Runnable () {@ Override public void run () {/ / create SimpleDateFormat object SimpleDateFormat simpleDateFormat = new SimpleDateFormat ("mm:ss") / / create time object Date date = new Date (finalI * 1000); / / execute time format and print the result System.out.println (simpleDateFormat.format (date));}}) } / / close the thread pool threadPool.shutdown () after the task is executed;}} this is the end of the article on "how java SimpleDateFormat converts local variables". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to convert local variables in java SimpleDateFormat". If you want to learn more knowledge, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.