prefuse.data.parser
Class DateParser

java.lang.Object
  extended by prefuse.data.parser.AbstractDateParser
      extended by prefuse.data.parser.DateParser
All Implemented Interfaces:
DataParser
Direct Known Subclasses:
DateTimeParser, TimeParser

public class DateParser
extends AbstractDateParser

DataParser instance that parses Date values as java.sql.Time instances, representing a particular date (but not a specific time on that day). This class uses a backing DateFormat instance to perform parsing. The DateFormat instance to use can be passed in to the constructor, or by default the DateFormat returned by DateFormat.getDateInstance(int) with an argument of DateFormat.SHORT is used.

Author:
jeffrey heer

Field Summary
protected  java.text.DateFormat m_dfmt
           
protected  java.text.ParsePosition m_pos
           
 
Constructor Summary
DateParser()
          Create a new DateParser.
DateParser(java.text.DateFormat dateFormat)
          Create a new DateParser.
DateParser(java.util.Locale locale)
           
 
Method Summary
 java.lang.Class<?> getType()
          Returns java.sql.Date.
 java.util.Date parseDate(java.lang.String text)
          Parse a Date value from a text string.
 
Methods inherited from class prefuse.data.parser.AbstractDateParser
canParse, format, parse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_dfmt

protected java.text.DateFormat m_dfmt

m_pos

protected java.text.ParsePosition m_pos
Constructor Detail

DateParser

public DateParser()
Create a new DateParser.


DateParser

public DateParser(java.text.DateFormat dateFormat)
Create a new DateParser.

Parameters:
dateFormat - the DateFormat instance to use for parsing

DateParser

public DateParser(java.util.Locale locale)
Method Detail

getType

public java.lang.Class<?> getType()
Returns java.sql.Date.

Specified by:
getType in interface DataParser
Specified by:
getType in class AbstractDateParser
Returns:
the parsed data type for this parser as a Java Class instance
See Also:
DataParser.getType()

parseDate

public java.util.Date parseDate(java.lang.String text)
                         throws DataParseException
Parse a Date value from a text string.

Specified by:
parseDate in class AbstractDateParser
Parameters:
text - the text string to parse
Returns:
the parsed Date value
Throws:
DataParseException - if an error occurs during parsing


Copyright © 2008 Regents of the University of California