blob: 6f761c08fc1c5c68889a1049809ce73fe061d591 [file] [log] [blame]
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Datetime patterns - Spark 3.2.0 Documentation</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
body {
padding-top: 60px;
padding-bottom: 40px;
}
</style>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/main.css">
<script src="js/vendor/modernizr-2.6.1-respond-1.1.0.min.js"></script>
<link rel="stylesheet" href="css/pygments-default.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
<link rel="stylesheet" href="css/docsearch.css">
<!-- Google analytics script -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-32518208-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<!--[if lt IE 7]>
<p class="chromeframe">You are using an outdated browser. <a href="https://browsehappy.com/">Upgrade your browser today</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to better experience this site.</p>
<![endif]-->
<!-- This code is taken from http://twitter.github.com/bootstrap/examples/hero.html -->
<nav class="navbar fixed-top navbar-expand-md navbar-light bg-light" id="topbar">
<div class="container">
<div class="navbar-header">
<div class="navbar-brand"><a href="index.html">
<img src="img/spark-logo-hd.png" style="height:50px;"/></a><span class="version">3.2.0</span>
</div>
</div>
<button class="navbar-toggler" type="button" data-toggle="collapse"
data-target="#navbarCollapse" aria-controls="navbarCollapse"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav">
<!--TODO(andyk): Add class="active" attribute to li some how.-->
<li class="nav-item"><a href="index.html" class="nav-link">Overview</a></li>
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" id="navbarQuickStart" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Programming Guides</a>
<div class="dropdown-menu" aria-labelledby="navbarQuickStart">
<a class="dropdown-item" href="quick-start.html">Quick Start</a>
<a class="dropdown-item" href="rdd-programming-guide.html">RDDs, Accumulators, Broadcasts Vars</a>
<a class="dropdown-item" href="sql-programming-guide.html">SQL, DataFrames, and Datasets</a>
<a class="dropdown-item" href="structured-streaming-programming-guide.html">Structured Streaming</a>
<a class="dropdown-item" href="streaming-programming-guide.html">Spark Streaming (DStreams)</a>
<a class="dropdown-item" href="ml-guide.html">MLlib (Machine Learning)</a>
<a class="dropdown-item" href="graphx-programming-guide.html">GraphX (Graph Processing)</a>
<a class="dropdown-item" href="sparkr.html">SparkR (R on Spark)</a>
<a class="dropdown-item" href="api/python/getting_started/index.html">PySpark (Python on Spark)</a>
</div>
</li>
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" id="navbarAPIDocs" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">API Docs</a>
<div class="dropdown-menu" aria-labelledby="navbarAPIDocs">
<a class="dropdown-item" href="api/scala/org/apache/spark/index.html">Scala</a>
<a class="dropdown-item" href="api/java/index.html">Java</a>
<a class="dropdown-item" href="api/python/index.html">Python</a>
<a class="dropdown-item" href="api/R/index.html">R</a>
<a class="dropdown-item" href="api/sql/index.html">SQL, Built-in Functions</a>
</div>
</li>
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" id="navbarDeploying" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Deploying</a>
<div class="dropdown-menu" aria-labelledby="navbarDeploying">
<a class="dropdown-item" href="cluster-overview.html">Overview</a>
<a class="dropdown-item" href="submitting-applications.html">Submitting Applications</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="spark-standalone.html">Spark Standalone</a>
<a class="dropdown-item" href="running-on-mesos.html">Mesos</a>
<a class="dropdown-item" href="running-on-yarn.html">YARN</a>
<a class="dropdown-item" href="running-on-kubernetes.html">Kubernetes</a>
</div>
</li>
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" id="navbarMore" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">More</a>
<div class="dropdown-menu" aria-labelledby="navbarMore">
<a class="dropdown-item" href="configuration.html">Configuration</a>
<a class="dropdown-item" href="monitoring.html">Monitoring</a>
<a class="dropdown-item" href="tuning.html">Tuning Guide</a>
<a class="dropdown-item" href="job-scheduling.html">Job Scheduling</a>
<a class="dropdown-item" href="security.html">Security</a>
<a class="dropdown-item" href="hardware-provisioning.html">Hardware Provisioning</a>
<a class="dropdown-item" href="migration-guide.html">Migration Guide</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="building-spark.html">Building Spark</a>
<a class="dropdown-item" href="https://spark.apache.org/contributing.html">Contributing to Spark</a>
<a class="dropdown-item" href="https://spark.apache.org/third-party-projects.html">Third Party Projects</a>
</div>
</li>
<li class="nav-item">
<input type="text" id="docsearch-input" placeholder="Search the docs…">
</li>
</ul>
<!--<span class="navbar-text navbar-right"><span class="version-text">v3.2.0</span></span>-->
</div>
</div>
</nav>
<div class="container-wrapper">
<div class="left-menu-wrapper">
<div class="left-menu">
<h3><a href="sql-programming-guide.html">Spark SQL Guide</a></h3>
<ul>
<li>
<a href="sql-getting-started.html">
Getting Started
</a>
</li>
<li>
<a href="sql-data-sources.html">
Data Sources
</a>
</li>
<li>
<a href="sql-performance-tuning.html">
Performance Tuning
</a>
</li>
<li>
<a href="sql-distributed-sql-engine.html">
Distributed SQL Engine
</a>
</li>
<li>
<a href="sql-pyspark-pandas-with-arrow.html">
PySpark Usage Guide for Pandas with Apache Arrow
</a>
</li>
<li>
<a href="sql-migration-old.html">
Migration Guide
</a>
</li>
<li>
<a href="sql-ref.html">
SQL Reference
</a>
</li>
<ul>
<li>
<a href="sql-ref-ansi-compliance.html">
ANSI Compliance
</a>
</li>
<li>
<a href="sql-ref-datatypes.html">
Data Types
</a>
</li>
<li>
<a href="sql-ref-datetime-pattern.html">
<b>Datetime Pattern</b>
</a>
</li>
<li>
<a href="sql-ref-functions.html">
Functions
</a>
</li>
<li>
<a href="sql-ref-identifier.html">
Identifiers
</a>
</li>
<li>
<a href="sql-ref-literals.html">
Literals
</a>
</li>
<li>
<a href="sql-ref-null-semantics.html">
Null Semantics
</a>
</li>
<li>
<a href="sql-ref-syntax.html">
SQL Syntax
</a>
</li>
</ul>
</ul>
</div>
</div>
<input id="nav-trigger" class="nav-trigger" checked type="checkbox">
<label for="nav-trigger"></label>
<div class="content-with-sidebar mr-3" id="content">
<h1 class="title">Datetime Patterns for Formatting and Parsing</h1>
<p>There are several common scenarios for datetime usage in Spark:</p>
<ul>
<li>
<p>CSV/JSON datasources use the pattern string for parsing and formatting datetime content.</p>
</li>
<li>
<p>Datetime functions related to convert <code class="language-plaintext highlighter-rouge">StringType</code> to/from <code class="language-plaintext highlighter-rouge">DateType</code> or <code class="language-plaintext highlighter-rouge">TimestampType</code>.
For example, <code class="language-plaintext highlighter-rouge">unix_timestamp</code>, <code class="language-plaintext highlighter-rouge">date_format</code>, <code class="language-plaintext highlighter-rouge">to_unix_timestamp</code>, <code class="language-plaintext highlighter-rouge">from_unixtime</code>, <code class="language-plaintext highlighter-rouge">to_date</code>, <code class="language-plaintext highlighter-rouge">to_timestamp</code>, <code class="language-plaintext highlighter-rouge">from_utc_timestamp</code>, <code class="language-plaintext highlighter-rouge">to_utc_timestamp</code>, etc.</p>
</li>
</ul>
<p>Spark uses pattern letters in the following table for date and timestamp parsing and formatting:</p>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Meaning</th>
<th>Presentation</th>
<th>Examples</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>G</strong></td>
<td>era</td>
<td>text</td>
<td>AD; Anno Domini</td>
</tr>
<tr>
<td><strong>y</strong></td>
<td>year</td>
<td>year</td>
<td>2020; 20</td>
</tr>
<tr>
<td><strong>D</strong></td>
<td>day-of-year</td>
<td>number(3)</td>
<td>189</td>
</tr>
<tr>
<td><strong>M/L</strong></td>
<td>month-of-year</td>
<td>month</td>
<td>7; 07; Jul; July</td>
</tr>
<tr>
<td><strong>d</strong></td>
<td>day-of-month</td>
<td>number(3)</td>
<td>28</td>
</tr>
<tr>
<td><strong>Q/q</strong></td>
<td>quarter-of-year</td>
<td>number/text</td>
<td>3; 03; Q3; 3rd quarter</td>
</tr>
<tr>
<td><strong>E</strong></td>
<td>day-of-week</td>
<td>text</td>
<td>Tue; Tuesday</td>
</tr>
<tr>
<td><strong>F</strong></td>
<td>aligned day of week in month</td>
<td>number(1)</td>
<td>3</td>
</tr>
<tr>
<td><strong>a</strong></td>
<td>am-pm-of-day</td>
<td>am-pm</td>
<td>PM</td>
</tr>
<tr>
<td><strong>h</strong></td>
<td>clock-hour-of-am-pm (1-12)</td>
<td>number(2)</td>
<td>12</td>
</tr>
<tr>
<td><strong>K</strong></td>
<td>hour-of-am-pm (0-11)</td>
<td>number(2)</td>
<td>0</td>
</tr>
<tr>
<td><strong>k</strong></td>
<td>clock-hour-of-day (1-24)</td>
<td>number(2)</td>
<td>0</td>
</tr>
<tr>
<td><strong>H</strong></td>
<td>hour-of-day (0-23)</td>
<td>number(2)</td>
<td>0</td>
</tr>
<tr>
<td><strong>m</strong></td>
<td>minute-of-hour</td>
<td>number(2)</td>
<td>30</td>
</tr>
<tr>
<td><strong>s</strong></td>
<td>second-of-minute</td>
<td>number(2)</td>
<td>55</td>
</tr>
<tr>
<td><strong>S</strong></td>
<td>fraction-of-second</td>
<td>fraction</td>
<td>978</td>
</tr>
<tr>
<td><strong>V</strong></td>
<td>time-zone ID</td>
<td>zone-id</td>
<td>America/Los_Angeles; Z; -08:30</td>
</tr>
<tr>
<td><strong>z</strong></td>
<td>time-zone name</td>
<td>zone-name</td>
<td>Pacific Standard Time; PST</td>
</tr>
<tr>
<td><strong>O</strong></td>
<td>localized zone-offset</td>
<td>offset-O</td>
<td>GMT+8; GMT+08:00; UTC-08:00;</td>
</tr>
<tr>
<td><strong>X</strong></td>
<td>zone-offset &#8216;Z&#8217; for zero</td>
<td>offset-X</td>
<td>Z; -08; -0830; -08:30; -083015; -08:30:15;</td>
</tr>
<tr>
<td><strong>x</strong></td>
<td>zone-offset</td>
<td>offset-x</td>
<td>+0000; -08; -0830; -08:30; -083015; -08:30:15;</td>
</tr>
<tr>
<td><strong>Z</strong></td>
<td>zone-offset</td>
<td>offset-Z</td>
<td>+0000; -0800; -08:00;</td>
</tr>
<tr>
<td><strong>&#8216;</strong></td>
<td>escape for text</td>
<td>delimiter</td>
<td>&#160;</td>
</tr>
<tr>
<td><strong>&#8217;&#8216;</strong></td>
<td>single quote</td>
<td>literal</td>
<td>&#8217;</td>
</tr>
<tr>
<td><strong>[</strong></td>
<td>optional section start</td>
<td>&#160;</td>
<td>&#160;</td>
</tr>
<tr>
<td><strong>]</strong></td>
<td>optional section end</td>
<td>&#160;</td>
<td>&#160;</td>
</tr>
</tbody>
</table>
<p>The count of pattern letters determines the format.</p>
<ul>
<li>
<p>Text: The text style is determined based on the number of pattern letters used. Less than 4 pattern letters will use the short text form, typically an abbreviation, e.g. day-of-week Monday might output &#8220;Mon&#8221;. Exactly 4 pattern letters will use the full text form, typically the full description, e.g, day-of-week Monday might output &#8220;Monday&#8221;. 5 or more letters will fail.</p>
</li>
<li>
<p>Number(n): The n here represents the maximum count of letters this type of datetime pattern can be used. If the count of letters is one, then the value is output using the minimum number of digits and without padding. Otherwise, the count of digits is used as the width of the output field, with the value zero-padded as necessary.</p>
</li>
<li>
<p>Number/Text: If the count of pattern letters is 3 or greater, use the Text rules above. Otherwise use the Number rules above.</p>
</li>
<li>
<p>Fraction: Use one or more (up to 9) contiguous <code class="language-plaintext highlighter-rouge">'S'</code> characters, e,g <code class="language-plaintext highlighter-rouge">SSSSSS</code>, to parse and format fraction of second.
For parsing, the acceptable fraction length can be [1, the number of contiguous &#8216;S&#8217;].
For formatting, the fraction length would be padded to the number of contiguous &#8216;S&#8217; with zeros.
Spark supports datetime of micro-of-second precision, which has up to 6 significant digits, but can parse nano-of-second with exceeded part truncated.</p>
</li>
<li>
<p>Year: The count of letters determines the minimum field width below which padding is used. If the count of letters is two, then a reduced two digit form is used. For printing, this outputs the rightmost two digits. For parsing, this will parse using the base value of 2000, resulting in a year within the range 2000 to 2099 inclusive. If the count of letters is less than four (but not two), then the sign is only output for negative years. Otherwise, the sign is output if the pad width is exceeded when &#8216;G&#8217; is not present. 7 or more letters will fail.</p>
</li>
<li>Month: It follows the rule of Number/Text. The text form is depend on letters - &#8216;M&#8217; denotes the &#8216;standard&#8217; form, and &#8216;L&#8217; is for &#8216;stand-alone&#8217; form. These two forms are different only in some certain languages. For example, in Russian, &#8216;Июль&#8217; is the stand-alone form of July, and &#8216;Июля&#8217; is the standard form. Here are examples for all supported pattern letters:
<ul>
<li><code class="language-plaintext highlighter-rouge">'M'</code> or <code class="language-plaintext highlighter-rouge">'L'</code>: Month number in a year starting from 1. There is no difference between &#8216;M&#8217; and &#8216;L&#8217;. Month from 1 to 9 are printed without padding.
<div class="language-sql highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">spark</span><span class="o">-</span><span class="k">sql</span><span class="o">&gt;</span> <span class="k">select</span> <span class="n">date_format</span><span class="p">(</span><span class="nb">date</span> <span class="s1">'1970-01-01'</span><span class="p">,</span> <span class="nv">"M"</span><span class="p">);</span>
<span class="mi">1</span>
<span class="n">spark</span><span class="o">-</span><span class="k">sql</span><span class="o">&gt;</span> <span class="k">select</span> <span class="n">date_format</span><span class="p">(</span><span class="nb">date</span> <span class="s1">'1970-12-01'</span><span class="p">,</span> <span class="nv">"L"</span><span class="p">);</span>
<span class="mi">12</span>
</code></pre></div> </div>
</li>
<li><code class="language-plaintext highlighter-rouge">'MM'</code> or <code class="language-plaintext highlighter-rouge">'LL'</code>: Month number in a year starting from 1. Zero padding is added for month 1-9.
<div class="language-sql highlighter-rouge"><div class="highlight"><pre class="highlight"><code> <span class="n">spark</span><span class="o">-</span><span class="k">sql</span><span class="o">&gt;</span> <span class="k">select</span> <span class="n">date_format</span><span class="p">(</span><span class="nb">date</span> <span class="s1">'1970-1-01'</span><span class="p">,</span> <span class="nv">"LL"</span><span class="p">);</span>
<span class="mi">01</span>
<span class="n">spark</span><span class="o">-</span><span class="k">sql</span><span class="o">&gt;</span> <span class="k">select</span> <span class="n">date_format</span><span class="p">(</span><span class="nb">date</span> <span class="s1">'1970-09-01'</span><span class="p">,</span> <span class="nv">"MM"</span><span class="p">);</span>
<span class="mi">09</span>
</code></pre></div> </div>
</li>
<li><code class="language-plaintext highlighter-rouge">'MMM'</code>: Short textual representation in the standard form. The month pattern should be a part of a date pattern not just a stand-alone month except locales where there is no difference between stand and stand-alone forms like in English.
<div class="language-sql highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">spark</span><span class="o">-</span><span class="k">sql</span><span class="o">&gt;</span> <span class="k">select</span> <span class="n">date_format</span><span class="p">(</span><span class="nb">date</span> <span class="s1">'1970-01-01'</span><span class="p">,</span> <span class="nv">"d MMM"</span><span class="p">);</span>
<span class="mi">1</span> <span class="n">Jan</span>
<span class="n">spark</span><span class="o">-</span><span class="k">sql</span><span class="o">&gt;</span> <span class="k">select</span> <span class="n">to_csv</span><span class="p">(</span><span class="n">named_struct</span><span class="p">(</span><span class="s1">'date'</span><span class="p">,</span> <span class="nb">date</span> <span class="s1">'1970-01-01'</span><span class="p">),</span> <span class="k">map</span><span class="p">(</span><span class="s1">'dateFormat'</span><span class="p">,</span> <span class="s1">'dd MMM'</span><span class="p">,</span> <span class="s1">'locale'</span><span class="p">,</span> <span class="s1">'RU'</span><span class="p">));</span>
<span class="mi">01</span> <span class="err">янв</span><span class="p">.</span>
</code></pre></div> </div>
</li>
<li><code class="language-plaintext highlighter-rouge">'LLL'</code>: Short textual representation in the stand-alone form. It should be used to format/parse only months without any other date fields.
<div class="language-sql highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">spark</span><span class="o">-</span><span class="k">sql</span><span class="o">&gt;</span> <span class="k">select</span> <span class="n">date_format</span><span class="p">(</span><span class="nb">date</span> <span class="s1">'1970-01-01'</span><span class="p">,</span> <span class="nv">"LLL"</span><span class="p">);</span>
<span class="n">Jan</span>
<span class="n">spark</span><span class="o">-</span><span class="k">sql</span><span class="o">&gt;</span> <span class="k">select</span> <span class="n">to_csv</span><span class="p">(</span><span class="n">named_struct</span><span class="p">(</span><span class="s1">'date'</span><span class="p">,</span> <span class="nb">date</span> <span class="s1">'1970-01-01'</span><span class="p">),</span> <span class="k">map</span><span class="p">(</span><span class="s1">'dateFormat'</span><span class="p">,</span> <span class="s1">'LLL'</span><span class="p">,</span> <span class="s1">'locale'</span><span class="p">,</span> <span class="s1">'RU'</span><span class="p">));</span>
<span class="err">янв</span><span class="p">.</span>
</code></pre></div> </div>
</li>
<li><code class="language-plaintext highlighter-rouge">'MMMM'</code>: full textual month representation in the standard form. It is used for parsing/formatting months as a part of dates/timestamps.
<div class="language-sql highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">spark</span><span class="o">-</span><span class="k">sql</span><span class="o">&gt;</span> <span class="k">select</span> <span class="n">date_format</span><span class="p">(</span><span class="nb">date</span> <span class="s1">'1970-01-01'</span><span class="p">,</span> <span class="nv">"d MMMM"</span><span class="p">);</span>
<span class="mi">1</span> <span class="n">January</span>
<span class="n">spark</span><span class="o">-</span><span class="k">sql</span><span class="o">&gt;</span> <span class="k">select</span> <span class="n">to_csv</span><span class="p">(</span><span class="n">named_struct</span><span class="p">(</span><span class="s1">'date'</span><span class="p">,</span> <span class="nb">date</span> <span class="s1">'1970-01-01'</span><span class="p">),</span> <span class="k">map</span><span class="p">(</span><span class="s1">'dateFormat'</span><span class="p">,</span> <span class="s1">'d MMMM'</span><span class="p">,</span> <span class="s1">'locale'</span><span class="p">,</span> <span class="s1">'RU'</span><span class="p">));</span>
<span class="mi">1</span> <span class="err">января</span>
</code></pre></div> </div>
</li>
<li><code class="language-plaintext highlighter-rouge">'LLLL'</code>: full textual month representation in the stand-alone form. The pattern can be used to format/parse only months.
<div class="language-sql highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">spark</span><span class="o">-</span><span class="k">sql</span><span class="o">&gt;</span> <span class="k">select</span> <span class="n">date_format</span><span class="p">(</span><span class="nb">date</span> <span class="s1">'1970-01-01'</span><span class="p">,</span> <span class="nv">"LLLL"</span><span class="p">);</span>
<span class="n">January</span>
<span class="n">spark</span><span class="o">-</span><span class="k">sql</span><span class="o">&gt;</span> <span class="k">select</span> <span class="n">to_csv</span><span class="p">(</span><span class="n">named_struct</span><span class="p">(</span><span class="s1">'date'</span><span class="p">,</span> <span class="nb">date</span> <span class="s1">'1970-01-01'</span><span class="p">),</span> <span class="k">map</span><span class="p">(</span><span class="s1">'dateFormat'</span><span class="p">,</span> <span class="s1">'LLLL'</span><span class="p">,</span> <span class="s1">'locale'</span><span class="p">,</span> <span class="s1">'RU'</span><span class="p">));</span>
<span class="err">январь</span>
</code></pre></div> </div>
</li>
</ul>
</li>
<li>
<p>am-pm: This outputs the am-pm-of-day. Pattern letter count must be 1.</p>
</li>
<li>
<p>Zone ID(V): This outputs the display the time-zone ID. Pattern letter count must be 2.</p>
</li>
<li>
<p>Zone names(z): This outputs the display textual name of the time-zone ID. If the count of letters is one, two or three, then the short name is output. If the count of letters is four, then the full name is output. Five or more letters will fail.</p>
</li>
<li>
<p>Offset X and x: This formats the offset based on the number of pattern letters. One letter outputs just the hour, such as &#8216;+01&#8217;, unless the minute is non-zero in which case the minute is also output, such as &#8216;+0130&#8217;. Two letters outputs the hour and minute, without a colon, such as &#8216;+0130&#8217;. Three letters outputs the hour and minute, with a colon, such as &#8216;+01:30&#8217;. Four letters outputs the hour and minute and optional second, without a colon, such as &#8216;+013015&#8217;. Five letters outputs the hour and minute and optional second, with a colon, such as &#8216;+01:30:15&#8217;. Six or more letters will fail. Pattern letter &#8216;X&#8217; (upper case) will output &#8216;Z&#8217; when the offset to be output would be zero, whereas pattern letter &#8216;x&#8217; (lower case) will output &#8216;+00&#8217;, &#8216;+0000&#8217;, or &#8216;+00:00&#8217;.</p>
</li>
<li>
<p>Offset O: This formats the localized offset based on the number of pattern letters. One letter outputs the short form of the localized offset, which is localized offset text, such as &#8216;GMT&#8217;, with hour without leading zero, optional 2-digit minute and second if non-zero, and colon, for example &#8216;GMT+8&#8217;. Four letters outputs the full form, which is localized offset text, such as &#8216;GMT, with 2-digit hour and minute field, optional second field if non-zero, and colon, for example &#8216;GMT+08:00&#8217;. Any other count of letters will fail.</p>
</li>
<li>
<p>Offset Z: This formats the offset based on the number of pattern letters. One, two or three letters outputs the hour and minute, without a colon, such as &#8216;+0130&#8217;. The output will be &#8216;+0000&#8217; when the offset is zero. Four letters outputs the full form of localized offset, equivalent to four letters of Offset-O. The output will be the corresponding localized offset text if the offset is zero. Five letters outputs the hour, minute, with optional second if non-zero, with colon. It outputs &#8216;Z&#8217; if the offset is zero. Six or more letters will fail.</p>
</li>
<li>
<p>Optional section start and end: Use <code class="language-plaintext highlighter-rouge">[]</code> to define an optional section and maybe nested.
During formatting, all valid data will be output even it is in the optional section.
During parsing, the whole section may be missing from the parsed string.
An optional section is started by <code class="language-plaintext highlighter-rouge">[</code> and ended using <code class="language-plaintext highlighter-rouge">]</code> (or at the end of the pattern).</p>
</li>
<li>Symbols of &#8216;E&#8217;, &#8216;F&#8217;, &#8216;q&#8217; and &#8216;Q&#8217; can only be used for datetime formatting, e.g. <code class="language-plaintext highlighter-rouge">date_format</code>. They are not allowed used for datetime parsing, e.g. <code class="language-plaintext highlighter-rouge">to_timestamp</code>.</li>
</ul>
</div>
<!-- /container -->
</div>
<script src="js/vendor/jquery-3.5.1.min.js"></script>
<script src="js/vendor/bootstrap.bundle.min.js"></script>
<script src="js/vendor/anchor.min.js"></script>
<script src="js/main.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
<script type="text/javascript">
// DocSearch is entirely free and automated. DocSearch is built in two parts:
// 1. a crawler which we run on our own infrastructure every 24 hours. It follows every link
// in your website and extract content from every page it traverses. It then pushes this
// content to an Algolia index.
// 2. a JavaScript snippet to be inserted in your website that will bind this Algolia index
// to your search input and display its results in a dropdown UI. If you want to find more
// details on how works DocSearch, check the docs of DocSearch.
docsearch({
apiKey: 'b18ca3732c502995563043aa17bc6ecb',
indexName: 'apache_spark',
inputSelector: '#docsearch-input',
enhancedSearchInput: true,
algoliaOptions: {
'facetFilters': ["version:3.2.0"]
},
debug: false // Set debug to true if you want to inspect the dropdown
});
</script>
<!-- MathJax Section -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: { equationNumbers: { autoNumber: "AMS" } }
});
</script>
<script>
// Note that we load MathJax this way to work with local file (file://), HTTP and HTTPS.
// We could use "//cdn.mathjax...", but that won't support "file://".
(function(d, script) {
script = d.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.onload = function(){
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ["$", "$"], ["\\\\(","\\\\)"] ],
displayMath: [ ["$$","$$"], ["\\[", "\\]"] ],
processEscapes: true,
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre']
}
});
};
script.src = ('https:' == document.location.protocol ? 'https://' : 'http://') +
'cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js' +
'?config=TeX-AMS-MML_HTMLorMML';
d.getElementsByTagName('head')[0].appendChild(script);
}(document));
</script>
</body>
</html>