import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class Main {
/**
* @param args
* @throws IOException
*/
updateSingaporeHolidayCalendar();
}
public static void updateSingaporeHolidayCalendar
() throws IOException{
String url
= "http://w...content-available-to-author-only...v.sg/employment-practices/leave-and-holidays/Pages/public-holidays-2014.aspx"; Document document
= Jsoup.
connect(url
).
get();
Elements holidays = document.select("#contentarea table tr");
// System.out.println("12312312");
//System.out.println("web page context: " + question);
List<String> el = new ArrayList<String>();
for(int i = 2; i < holidays.size() + 1; i++){
if((i&1) == 1) continue;
Elements threeGroup = holidays.get(i-2).getElementsByTag("td");
int j = 2;
if(j-- != 0) continue;
j = 2;
el.add(e.text());
}
}
Pattern pattern = Pattern.compile("(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)(\\*){0,2}\\s+\\d{1,2}\\s+(January|February|March|April|May|June|July|August|September|October|November|December)\\s+\\d{4}");
//out put
for(int k = 0; k < el.size(); k++){
Matcher matcher = pattern.matcher(el.get(k));
// Check all occurrences
while (matcher.find()) {
//System.out.print("Start index: " + matcher.start());
//System.out.print(" End index: " + matcher.end());
System.
out.
println(" Found: " + matcher.
group()); }
System.
out.
println("holiday: " + el.
get(k
)); }
}
}