- Forum posts: 8
Feb 24, 2016, 8:27:42 AM via Website
Feb 24, 2016 8:27:42 AM via Website
I am developing an android application in which i want to parser the date, time and string that is what Natty (Date Parser) do is exactly needed for me. I have tried in eclipse IDE. I have manually added the following jar files.
antlr-2.7.7.jar
antlr-runtime-3.2.jar
backport-util-concurrent-3.1.jar
commons-codec-1.5.jar
commons-lang-2.6.jar
commons-logging-1.1.1.jar
ical4j-1.0.2.jar
stringtemplate-3.2.jar
And i have followed the instructions given in Natty website. That is in POM file,i have added the dependency as
<dependency>;
<groupId>com.joestelmach</groupId>
<artifactId>natty</artifactId>
<version>0.11</version>
</dependency>
and added the following in main java file.
import com.joestelmach.natty.*;
Parser parser = new Parser();
List groups = parser.parse("the day before next thursday");
for(DateGroup group:groups) {
List dates = group.getDates();
int line = group.getLine();
int column = group.getPosition();
String matchingValue = group.getText();
String syntaxTree = group.getSyntaxTree().toStringTree();
Map parseMap = group.getParseLocations();
boolean isRecurreing = group.isRecurring();
Date recursUntil = group.getRecursUntil();
}
I have imported three libraries.
import java.util.Date;
import java.util.List;
import java.util.Map;
Now i am getting an error in this line.
for(DateGroup group:groups)
Error: Type mismatch: cannot convert from element type Object to DateGroup.
Please suggest me some solutions for this.
I have added the Parser class under onCreateOptionsMenu function.
Or please suggest me some other solutions for me to parse the date,time and string from a sentence. For example, consider the following sentence "Lets go for lunch on July 17th 2016 at 1 pm", from this i need to extract Date:17th July 2016, time 1 pm and string : Lets go for lunch.
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.