?? archiveutils.html
字號:
W3C/ISO8601 format, assuming UTC. Format is yyyy-MM-dd'T'HH:mm:ss.SSS'Z'<P><DD><DL><DT><B>Parameters:</B><DD><CODE>date</CODE> - Date to format.<DT><B>Returns:</B><DD>the date stamp</DL></DD></DL><HR><A NAME="getLog14Date()"><!-- --></A><H3>getLog14Date</H3><PRE>public static java.lang.String <B>getLog14Date</B>()</PRE><DL><DD>Utility function for creating log timestamps, in W3C/ISO8601 format, assuming UTC. Use current time. Format is yyyy-MM-dd'T'HH:mm:ss'Z'<P><DD><DL><DT><B>Returns:</B><DD>the date stamp</DL></DD></DL><HR><A NAME="getLog14Date(long)"><!-- --></A><H3>getLog14Date</H3><PRE>public static java.lang.String <B>getLog14Date</B>(long date)</PRE><DL><DD>Utility function for creating log timestamps, in W3C/ISO8601 format, assuming UTC. Format is yyyy-MM-dd'T'HH:mm:ss'Z'<P><DD><DL><DT><B>Parameters:</B><DD><CODE>date</CODE> - long timestamp to format.<DT><B>Returns:</B><DD>the date stamp</DL></DD></DL><HR><A NAME="getLog14Date(java.util.Date)"><!-- --></A><H3>getLog14Date</H3><PRE>public static java.lang.String <B>getLog14Date</B>(java.util.Date date)</PRE><DL><DD>Utility function for creating log timestamps, in W3C/ISO8601 format, assuming UTC. Format is yyyy-MM-dd'T'HH:mm:ss'Z'<P><DD><DL><DT><B>Parameters:</B><DD><CODE>date</CODE> - Date to format.<DT><B>Returns:</B><DD>the date stamp</DL></DD></DL><HR><A NAME="get17DigitDate(long)"><!-- --></A><H3>get17DigitDate</H3><PRE>public static java.lang.String <B>get17DigitDate</B>(long date)</PRE><DL><DD>Utility function for creating arc-style date stamps in the format yyyyMMddHHmmssSSS. Date stamps are in the UTC time zone<P><DD><DL><DT><B>Parameters:</B><DD><CODE>date</CODE> - milliseconds since epoc<DT><B>Returns:</B><DD>the date stamp</DL></DD></DL><HR><A NAME="get17DigitDate(java.util.Date)"><!-- --></A><H3>get17DigitDate</H3><PRE>public static java.lang.String <B>get17DigitDate</B>(java.util.Date date)</PRE><DL><DD><DL></DL></DD></DL><HR><A NAME="get14DigitDate(long)"><!-- --></A><H3>get14DigitDate</H3><PRE>public static java.lang.String <B>get14DigitDate</B>(long date)</PRE><DL><DD>Utility function for creating arc-style date stamps in the format yyyyMMddHHmmss. Date stamps are in the UTC time zone<P><DD><DL><DT><B>Parameters:</B><DD><CODE>date</CODE> - milliseconds since epoc<DT><B>Returns:</B><DD>the date stamp</DL></DD></DL><HR><A NAME="get14DigitDate(java.util.Date)"><!-- --></A><H3>get14DigitDate</H3><PRE>public static java.lang.String <B>get14DigitDate</B>(java.util.Date d)</PRE><DL><DD><DL></DL></DD></DL><HR><A NAME="get12DigitDate(long)"><!-- --></A><H3>get12DigitDate</H3><PRE>public static java.lang.String <B>get12DigitDate</B>(long date)</PRE><DL><DD>Utility function for creating arc-style date stamps in the format yyyyMMddHHmm. Date stamps are in the UTC time zone<P><DD><DL><DT><B>Parameters:</B><DD><CODE>date</CODE> - milliseconds since epoc<DT><B>Returns:</B><DD>the date stamp</DL></DD></DL><HR><A NAME="get12DigitDate(java.util.Date)"><!-- --></A><H3>get12DigitDate</H3><PRE>public static java.lang.String <B>get12DigitDate</B>(java.util.Date d)</PRE><DL><DD><DL></DL></DD></DL><HR><A NAME="getDate(java.lang.String)"><!-- --></A><H3>getDate</H3><PRE>public static java.util.Date <B>getDate</B>(java.lang.String d) throws java.text.ParseException</PRE><DL><DD>Parses an ARC-style date. If passed String is < 12 characters in length, we pad. At a minimum, String should contain a year (>=4 characters). Parse will also fail if day or month are incompletely specified. Depends on the above getXXDigitDate methods.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>A</CODE> - 4-17 digit date in ARC style (<code>yyyy</code> to <code>yyyyMMddHHmmssSSS</code>) formatting.<DT><B>Returns:</B><DD>A Date object representing the passed String.<DT><B>Throws:</B><DD><CODE>java.text.ParseException</CODE></DL></DD></DL><HR><A NAME="parse17DigitDate(java.lang.String)"><!-- --></A><H3>parse17DigitDate</H3><PRE>public static java.util.Date <B>parse17DigitDate</B>(java.lang.String date) throws java.text.ParseException</PRE><DL><DD>Utility function for parsing arc-style date stamps in the format yyyMMddHHmmssSSS. Date stamps are in the UTC time zone. The whole string will not be parsed, only the first 17 digits.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>date</CODE> - an arc-style formatted date stamp<DT><B>Returns:</B><DD>the Date corresponding to the date stamp string<DT><B>Throws:</B><DD><CODE>java.text.ParseException</CODE> - if the inputstring was malformed</DL></DD></DL><HR><A NAME="parse14DigitDate(java.lang.String)"><!-- --></A><H3>parse14DigitDate</H3><PRE>public static java.util.Date <B>parse14DigitDate</B>(java.lang.String date) throws java.text.ParseException</PRE><DL><DD>Utility function for parsing arc-style date stamps in the format yyyMMddHHmmss. Date stamps are in the UTC time zone. The whole string will not be parsed, only the first 14 digits.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>date</CODE> - an arc-style formatted date stamp<DT><B>Returns:</B><DD>the Date corresponding to the date stamp string<DT><B>Throws:</B><DD><CODE>java.text.ParseException</CODE> - if the inputstring was malformed</DL></DD></DL><HR><A NAME="parse12DigitDate(java.lang.String)"><!-- --></A><H3>parse12DigitDate</H3><PRE>public static java.util.Date <B>parse12DigitDate</B>(java.lang.String date) throws java.text.ParseException</PRE><DL><DD>Utility function for parsing arc-style date stamps in the format yyyMMddHHmm. Date stamps are in the UTC time zone. The whole string will not be parsed, only the first 12 digits.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>date</CODE> - an arc-style formatted date stamp<DT><B>Returns:</B><DD>the Date corresponding to the date stamp string<DT><B>Throws:</B><DD><CODE>java.text.ParseException</CODE> - if the inputstring was malformed</DL></DD></DL><HR><A NAME="timestamp17ToCalendar(java.lang.String)"><!-- --></A><H3>timestamp17ToCalendar</H3><PRE>public static java.util.Calendar <B>timestamp17ToCalendar</B>(java.lang.String timestamp17String)</PRE><DL><DD>Convert 17-digit date format timestamps (as found in crawl.log, for example) into a GregorianCalendar object. + * Useful so you can convert into milliseconds-since-epoch. Note: it is possible to compute milliseconds-since-epoch + * using <A HREF="../../../org/archive/util/ArchiveUtils.html#parse17DigitDate(java.lang.String)"><CODE>parse17DigitDate(java.lang.String)</CODE></A>.UTC(), but that method is deprecated in favor of using Calendar.getTimeInMillis(). + * <p/>I probably should have dug into all the utility methods in DateFormat.java to parse the timestamp, but this was + * easier. If someone wants to fix this to use those methods, please have at it! <p/> Mike Schwartz, schwartz at CodeOnTheRoad dot com.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>timestamp17String</CODE> - <DT><B>Returns:</B><DD>Calendar set to <code>timestamp17String</code>.</DL></DD></DL><HR><A NAME="secondsSinceEpoch(java.lang.String)"><!-- --></A><H3>secondsSinceEpoch</H3><PRE>public static java.lang.String <B>secondsSinceEpoch</B>(java.lang.String timestamp) throws java.text.ParseException</PRE><DL><DD><DL><DT><B>Parameters:</B><DD><CODE>timestamp</CODE> - A 14-digit timestamp or the suffix for a 14-digit timestamp: E.g. '20010909014640' or '20010101' or '1970'.<DT><B>Returns:</B><DD>Seconds since the epoch as a string zero-pre-padded so always Integer.MAX_VALUE wide (Makes it so sorting of resultant string works properly).<DT><B>Throws:</B><DD><CODE>java.text.ParseException</CODE></DL></DD></DL><HR><A NAME="getSecondsSinceEpoch(java.lang.String)"><!-- --></A><H3>getSecondsSinceEpoch</H3><PRE>public static java.util.Date <B>getSecondsSinceEpoch</B>(java.lang.String timestamp) throws java.text.ParseException</PRE><DL><DD><DL><DT><B>Parameters:</B><DD><CODE>timestamp</CODE> - A 14-digit timestamp or the suffix for a 14-digit timestamp: E.g. '20010909014640' or '20010101' or '1970'.<DT><B>Returns:</B><DD>A date.<DT><B>Throws:</B><DD><CODE>java.text.ParseException</CODE><DT><B>See Also:</B><DD><A HREF="../../../org/archive/util/ArchiveUtils.html#secondsSinceEpoch(java.lang.String)"><CODE>secondsSinceEpoch(String)</CODE></A></DL></DD></DL><HR><A NAME="zeroPadInteger(int)"><!-- --></A><H3>zeroPadInteger</H3><PRE>public static java.lang.String <B>zeroPadInteger</B>(int i)</PRE><DL><DD><DL><DT><B>Parameters:</B><DD><CODE>i</CODE> - Integer to add prefix of zeros too. If passed 2005, will return the String <code>0000002005</code>. String width is the width of Integer.MAX_VALUE as a string (10 digits).<DT><B>Returns:</B><DD>Padded String version of <code>i</code>.</DL></DD></DL><HR><A NAME="padTo(int, int)"><!-- --></A><H3>padTo</H3><PRE>public static java.lang.String <B>padTo</B>(int i, int pad)</PRE><DL><DD>Convert an <code>int</code> to a <code>String</code>, and pad it to <code>pad</code> spaces.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>i</CODE> - the int<DD><CODE>pad</CODE> - the width to pad to.<DT><B>Returns:</B><DD>String w/ padding.</DL></DD></DL><HR>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -