ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/util/http/ConcurrentDateFormat.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/util/http/ConcurrentDateFormat.java
Status
scanned
Type
file
Name
ConcurrentDateFormat.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
2568 (2.5 KB)
MD5
e495aefef720668a7ba340908c920c6a
SHA1
d91c32579d415969a281d5812f8abbce6553b9e2
SHA256
48ace0b53e5d3837744d945331d8d7f7e62d5e4ddedc29a4ab50987c0ea900a4
SHA512

      
    
SHA1_git
26a577696e3517f14dd8b422d03d4e839dfa867d
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ConcurrentDateFormat.java | 2.5 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tomcat.util.http; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.Queue; import java.util.TimeZone; import java.util.concurrent.ConcurrentLinkedQueue; /** * A thread safe wrapper around {@link SimpleDateFormat} that does not make use of ThreadLocal and - broadly - only * creates enough SimpleDateFormat objects to satisfy the concurrency requirements. */ public class ConcurrentDateFormat { private final String format; private final Locale locale; private final TimeZone timezone; private final Queue<SimpleDateFormat> queue = new ConcurrentLinkedQueue<>(); public ConcurrentDateFormat(String format, Locale locale, TimeZone timezone) { this.format = format; this.locale = locale; this.timezone = timezone; SimpleDateFormat initial = createInstance(); queue.add(initial); } public String format(Date date) { SimpleDateFormat sdf = queue.poll(); if (sdf == null) { sdf = createInstance(); } String result = sdf.format(date); queue.add(sdf); return result; } public Date parse(String source) throws ParseException { SimpleDateFormat sdf = queue.poll(); if (sdf == null) { sdf = createInstance(); } Date result = sdf.parse(source); sdf.setTimeZone(timezone); queue.add(sdf); return result; } private SimpleDateFormat createInstance() { SimpleDateFormat sdf = new SimpleDateFormat(format, locale); sdf.setTimeZone(timezone); return sdf; } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
41.03
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9