package votorola.g.text; // Copyright 2009, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. import votorola.g.lang.*; /** SimpleDateFormat utilities. */ public @ThreadSafe final class SimpleDateFormatX { private SimpleDateFormatX() {} /** An ISO 8601 format pattern for local times. * * @see http://en.wikipedia.org/wiki/ISO_8601 */ public static final String ISO_8601_LOCAL_PATTERN = "yyyy-MM-dd'T'HH:mm:ss"; /** An ISO 8601 format pattern (wrong). When parsing a value in timezone Z (GMT), the * input needs to be {@linkplain #simplifiedISO8601(String) dumbed down}. In a "GMT" * timezone, the output probably needs correcting. * *

This is wrong because it uses a named timezone.

* * @see http://en.wikipedia.org/wiki/ISO_8601 */ public static final String ISO_8601_PATTERN = "yyyy-MM-dd'T'HH:mm:ssz"; /** An ISO 8601 format pattern (corrected). * * @see http://en.wikipedia.org/wiki/ISO_8601 */ public static final String ISO_8601_PATTERN_C = "yyyy-MM-dd'T'HH:mm:ssZ"; /** Simplifies an ISO 8601 format string, for parsing against {@linkplain * #ISO_8601_PATTERN ISO_8601_PATTERN}. */ public static String simplifiedISO8601( String s ) { if( s.charAt(19) == 'Z' && s.length() == 20 ) s = s.substring(0,19) + "GMT"; // it cannot parse the Z, so help it out return s; } }