Skip to content

Instantly share code, notes, and snippets.

@nkmhang
nkmhang / survey.html
Created May 16, 2020
capture Image and upload it into Imgur
View survey.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>SURVEY</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="http://www.shieldui.com/shared/components/latest/css/light-bootstrap/all.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script type="text/javascript" src="http://www.shieldui.com/shared/components/latest/js/shieldui-all.min.js"></script>
View CalculateAction.java
btnCalculate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
HighLightEvaluator highlight = new HighLightEvaluator();
DeSelectHighlightEvaluator deSelectHighlight = new DeSelectHighlightEvaluator();
//remove all highlight
if(!deSelectDays.isEmpty()) {
for(Date deSelectDate : deSelectDays) {
deSelectHighlight.add(deSelectDate);
}
View ShowHolidaysAction.java
btnLoadFromTxt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
HolidayEvaluator holidayHighligh = new HolidayEvaluator();
service.readDataFromTxt(holidays);
for(Date holiday : holidays) {
holidayHighligh.add(holiday);
}
holidaySetting.getDayChooser().addDateEvaluator(holidayHighligh);
holidaySetting.setCalendar(holidaySetting.getCalendar());
View SetUpHolidaysAction.java
btnSaveToTxt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
service.setSundayToHolidays(holidays);
service.writeDataToTxt(holidays);
ResourceBundleHelper resourceBundle = new ResourceBundleHelper();
JOptionPane.showMessageDialog(frmCalculateWorkingDays,resourceBundle.getWord(lang, "success"));
}
});
View JCalendarAction.java
List<Date> deSelectDays = new ArrayList<>();
Set<Date> holidays = new HashSet<>();
Set<Date> deSelectHolidays = new HashSet<>();
holidaySetting.getDayChooser().addPropertyChangeListener("day", new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent e) {
HolidayEvaluator holidayHighligh = new HolidayEvaluator();
DeSelectHighlightEvaluator deSelectHighlight = new DeSelectHighlightEvaluator();
Calendar c = Calendar.getInstance();
View readDataFromTxt.java
public void readDataFromTxt(Set<Date> holidays) {
BufferedReader br = null;
String thisLine = null;
try {
br = new BufferedReader(new FileReader("D:\\holidays.txt"));
while ((thisLine = br.readLine()) != null) {
Date holiday = dt.parse(thisLine);
holidays.add(holiday);
}
View writeDataToTxt.java
public void writeDataToTxt(Set<Date> holidays) {
PrintWriter printWriter = null;
try {
printWriter = new PrintWriter("D:\\holidays.txt");
for(Date holiday : holidays) {
printWriter.println(dt.format(holiday));
}
}catch(Exception e) {
e.printStackTrace();
}finally {
View setSundayToHolidays.java
public Set<Date> setSundayToHolidays(Set<Date> holidays) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DATE,1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
calendar.set(Calendar.MONTH, Calendar.JANUARY);
Date start = calendar.getTime();
View iteratorBetweenTwoDates.java
public List<Date> iteratorBetweenTwoDates(Date fromDate, Date toDate, Set<Date> holidays) {
List<Date> daysRange = new ArrayList<>();
Calendar start = Calendar.getInstance();
start.setTime(fromDate);
Calendar end = Calendar.getInstance();
end.setTime(toDate);
while( !start.after(end)){
start.set(Calendar.HOUR_OF_DAY, 0);
start.set(Calendar.MINUTE, 0);
View DeSelectHighlightEvaluator.java
public class DeSelectHighlightEvaluator implements IDateEvaluator {
private final List<Date> list = new ArrayList<>();
public void add(Date date) {
list.add(date);
}
@Override
public boolean isSpecial(Date date) {
You can’t perform that action at this time.