Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String DATE_FORMAT = "yyyyMMdd";
- try {
- DateFormat dfyyyyMMdd = new SimpleDateFormat(DATE_FORMAT);
- dfyyyyMMdd.setLenient(false);
- Date formattedDate;
- formattedDate = dfyyyyMMdd.parse(aValue);
- console.debug(String.format("%s = %s","formattedDate",formattedDate));
- } catch (ParseException e) {
- // Not a date
- }
- ParsePosition pos = new ParsePosition(0);
- dfyyyyMMdd.parse(aValue, pos);
- if (pos.getIndex() != aValue.length()) {
- // there's garbage at the end
- }
- public Date parse(String source)
- throws ParseException
- Parses text from the beginning of the given string to produce a date.
- The method may not use the entire text of the given string.
- yyyyMMdd(followed by anything)
- "10000514blabla" --> Tue May 14 00:00:00 EST 1000
- "100 112" --> Sun Jan 12 00:00:00 EST 100
- "1 112xyz" --> Wed Jan 12 00:00:00 EST 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement