use of java.text.ParsePosition in project OpenAM by OpenRock.
the class Locale method parseDateString.
/**
* Gets Date object from date string with specified locale.
*
* @param dateString
* date string
* @param locale
* Locale object
* @param dateSyntax
* syntax of the date string.
*
* @return Date object returned if <code>dateString</code> matches the
* <code> dateSyntax</code>. If the syntax or date string is
* empty, or the string does not match the syntax, null will be
* returned.
*/
public static Date parseDateString(String dateString, java.util.Locale locale, String dateSyntax) {
if (debug.messageEnabled()) {
debug.message("Local.parseDateString(date, locale, syntax)");
debug.message("date string = " + dateString);
debug.message("date syntax = " + dateSyntax);
debug.message("locale = " + locale.toString());
}
if ((dateString == null) || (dateString.length() < 1) || (dateSyntax == null) || (dateSyntax.length() < 1)) {
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat(dateSyntax);
sdf.setLenient(false);
ParsePosition pos = new ParsePosition(0);
Date date = sdf.parse(dateString, pos);
if (date == null) {
debug.warning("Locale.parseDateString: unable to parse the date.");
}
return date;
}
use of java.text.ParsePosition in project tdi-studio-se by Talend.
the class BusinessAbstractParser method isValidEditString.
/**
* @generated NOT
*/
public IParserEditStatus isValidEditString(IAdaptable element, String editString) {
ParsePosition pos = new ParsePosition(0);
Object[] values = getEditProcessor().parse(editString, pos);
if (values == null) {
return new ParserEditStatus(BusinessDiagramEditorPlugin.ID, IParserEditStatus.UNEDITABLE, Messages.getString(//$NON-NLS-1$
"BusinessAbstractParser.InvalidInputAt") + pos.getErrorIndex());
}
return validateNewValues(values);
}
use of java.text.ParsePosition in project android_frameworks_base by ResurrectionRemix.
the class ExifInterface method getGpsDateTime.
/**
* Returns number of milliseconds since Jan. 1, 1970, midnight UTC.
* Returns -1 if the date time information if not available.
* @hide
*/
public long getGpsDateTime() {
String date = getAttribute(TAG_GPS_DATESTAMP);
String time = getAttribute(TAG_GPS_TIMESTAMP);
if (date == null || time == null || (!sNonZeroTimePattern.matcher(date).matches() && !sNonZeroTimePattern.matcher(time).matches())) {
return -1;
}
String dateTimeString = date + ' ' + time;
ParsePosition pos = new ParsePosition(0);
try {
Date datetime = sFormatter.parse(dateTimeString, pos);
if (datetime == null)
return -1;
return datetime.getTime();
} catch (IllegalArgumentException e) {
return -1;
}
}
use of java.text.ParsePosition in project jackson-databind by FasterXML.
the class ISO8601UtilsTest method testParseShortDateTime.
public void testParseShortDateTime() throws java.text.ParseException {
Date d = ISO8601Utils.parse("20070813T195123.789Z", new ParsePosition(0));
assertEquals(date, d);
d = ISO8601Utils.parse("20070813T195123Z", new ParsePosition(0));
assertEquals(dateZeroMillis, d);
d = ISO8601Utils.parse("20070813T215123.789+02:00", new ParsePosition(0));
assertEquals(date, d);
}
use of java.text.ParsePosition in project jackson-databind by FasterXML.
the class ISO8601UtilsTest method testParseWithoutTime.
public void testParseWithoutTime() throws ParseException {
Date d = ISO8601Utils.parse("2007-08-13Z", new ParsePosition(0));
assertEquals(dateWithoutTime, d);
d = ISO8601Utils.parse("20070813Z", new ParsePosition(0));
assertEquals(dateWithoutTime, d);
d = ISO8601Utils.parse("2007-08-13+00:00", new ParsePosition(0));
assertEquals(dateWithoutTime, d);
d = ISO8601Utils.parse("20070813+00:00", new ParsePosition(0));
assertEquals(dateWithoutTime, d);
}
Aggregations