// Path: happycoding/src/main/java/happy/coding/system/Dates.java
// public class Dates {
// 	public final static String PATTERN_yyyy_MM_dd = "yyyy-MM-dd";
// 	public final static String PATTERN_dd_MM_yyyy = "dd/MM/yyyy";
// 	public final static String PATTERN_MM_dd_yyyy = "MM/dd/yyyy";
// 	public final static String PATTERN_yyyy_MM_dd_HH_mm_SS = "yyyy-MM-dd HH-mm-SS";
// 
// 	private static final SimpleDateFormat sdf = new SimpleDateFormat(PATTERN_yyyy_MM_dd_HH_mm_SS);
// 
// 	public static java.sql.Date parse(String date) throws Exception {
// 		return parse(date, PATTERN_yyyy_MM_dd);
// 	}
// 
// 	public static java.sql.Date parse(String date, String pattern) throws Exception {
// 		SimpleDateFormat sdf = new SimpleDateFormat(pattern);
// 		return new java.sql.Date(sdf.parse(date).getTime());
// 	}
// 
// 	public static String toString(long mms, String pattern) throws Exception {
// 		SimpleDateFormat sdf = new SimpleDateFormat(pattern);
// 		return sdf.format(new java.sql.Date(mms));
// 	}
// 
// 	public static String toString(long mms) throws Exception {
// 		return sdf.format(new java.sql.Date(mms));
// 	}
// 
// 	public static String now() {
// 		return sdf.format(new java.util.Date());
// 	}
// 
// 	/**
// 	 * Convert time in milliseconds to human-readable format.
// 	 * 
// 	 * @param msType
// 	 *            The time in milliseconds
// 	 * @return a human-readable string version of the time
// 	 */
// 	public static String parse(long msType) {
// 		long original = msType;
// 		int ms = (int) (msType % 1000);
// 
// 		original = original / 1000;
// 		int sec = (int) (original % 60);
// 
// 		original = original / 60;
// 		int min = (int) (original % 60);
// 
// 		original = original / 60;
// 		int hr = (int) (original % 24);
// 
// 		original = original / 24;
// 		int day = (int) original;
// 
// 		if (day > 1) {
// 			return String.format("%d days, %02d:%02d:%02d.%03d", day, hr, min, sec, ms);
// 		} else if (day > 0) {
// 			return String.format("%d day, %02d:%02d:%02d.%03d", day, hr, min, sec, ms);
// 		} else if (hr > 0) {
// 			return String.format("%02d:%02d:%02d", hr, min, sec);
// 		} else {
// 			return String.format("%02d:%02d", min, sec);
// 		}
// 	}
// 
// }


import happy.coding.system.Dates;
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;

package happy.coding.io.net;



public class Gmailer extends EMailer {

	public Gmailer() {
		configSSL();
		defaultInstance();
	}

	public void configTLS() {
		props.put("mail.smtp.starttls.enable", "true");

		props.setProperty("mail.transport.protocol", "smtp");
		props.setProperty("mail.smtp.host", "smtp.gmail.com");
		props.setProperty("mail.smtp.port", "587");
		props.setProperty("mail.smtp.auth", "true");
	}

	public void configSSL() {
		props.put("mail.smtp.host", "smtp.gmail.com");
		props.put("mail.smtp.socketFactory.port", "465");
		props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
		props.put("mail.smtp.auth", "true");
		props.put("mail.smtp.port", "465");
	}

	private void defaultInstance() {
		props.setProperty("mail.debug", "false");

		final String userName = "happycodingprojects@gmail.com";
		final String password = "dailycoding@ntu";
		props.setProperty("mail.smtp.user", userName);
		props.setProperty("mail.smtp.password", password);

		props.setProperty("mail.from", userName);
		props.setProperty("mail.to", "gguo1@e.ntu.edu.sg");

		props.setProperty("mail.subject", "Program Notifier from Gmail");

// Path: happycoding/src/main/java/happy/coding/system/Dates.java
// public class Dates {
// 	public final static String PATTERN_yyyy_MM_dd = "yyyy-MM-dd";
// 	public final static String PATTERN_dd_MM_yyyy = "dd/MM/yyyy";
// 	public final static String PATTERN_MM_dd_yyyy = "MM/dd/yyyy";
// 	public final static String PATTERN_yyyy_MM_dd_HH_mm_SS = "yyyy-MM-dd HH-mm-SS";
// 
// 	private static final SimpleDateFormat sdf = new SimpleDateFormat(PATTERN_yyyy_MM_dd_HH_mm_SS);
// 
// 	public static java.sql.Date parse(String date) throws Exception {
// 		return parse(date, PATTERN_yyyy_MM_dd);
// 	}
// 
// 	public static java.sql.Date parse(String date, String pattern) throws Exception {
// 		SimpleDateFormat sdf = new SimpleDateFormat(pattern);
// 		return new java.sql.Date(sdf.parse(date).getTime());
// 	}
// 
// 	public static String toString(long mms, String pattern) throws Exception {
// 		SimpleDateFormat sdf = new SimpleDateFormat(pattern);
// 		return sdf.format(new java.sql.Date(mms));
// 	}
// 
// 	public static String toString(long mms) throws Exception {
// 		return sdf.format(new java.sql.Date(mms));
// 	}
// 
// 	public static String now() {
// 		return sdf.format(new java.util.Date());
// 	}
// 
// 	/**
// 	 * Convert time in milliseconds to human-readable format.
// 	 * 
// 	 * @param msType
// 	 *            The time in milliseconds
// 	 * @return a human-readable string version of the time
// 	 */
// 	public static String parse(long msType) {
// 		long original = msType;
// 		int ms = (int) (msType % 1000);
// 
// 		original = original / 1000;
// 		int sec = (int) (original % 60);
// 
// 		original = original / 60;
// 		int min = (int) (original % 60);
// 
// 		original = original / 60;
// 		int hr = (int) (original % 24);
// 
// 		original = original / 24;
// 		int day = (int) original;
// 
// 		if (day > 1) {
// 			return String.format("%d days, %02d:%02d:%02d.%03d", day, hr, min, sec, ms);
// 		} else if (day > 0) {
// 			return String.format("%d day, %02d:%02d:%02d.%03d", day, hr, min, sec, ms);
// 		} else if (hr > 0) {
// 			return String.format("%02d:%02d:%02d", hr, min, sec);
// 		} else {
// 			return String.format("%02d:%02d", min, sec);
// 		}
// 	}
// 
// }


// Path: happycoding/src/main/java/happy/coding/io/net/Gmailer.java
import happy.coding.system.Dates;
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;

package happy.coding.io.net;



public class Gmailer extends EMailer {

	public Gmailer() {
		configSSL();
		defaultInstance();
	}

	public void configTLS() {
		props.put("mail.smtp.starttls.enable", "true");

		props.setProperty("mail.transport.protocol", "smtp");
		props.setProperty("mail.smtp.host", "smtp.gmail.com");
		props.setProperty("mail.smtp.port", "587");
		props.setProperty("mail.smtp.auth", "true");
	}

	public void configSSL() {
		props.put("mail.smtp.host", "smtp.gmail.com");
		props.put("mail.smtp.socketFactory.port", "465");
		props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
		props.put("mail.smtp.auth", "true");
		props.put("mail.smtp.port", "465");
	}

	private void defaultInstance() {
		props.setProperty("mail.debug", "false");

		final String userName = "happycodingprojects@gmail.com";
		final String password = "dailycoding@ntu";
		props.setProperty("mail.smtp.user", userName);
		props.setProperty("mail.smtp.password", password);

		props.setProperty("mail.from", userName);
		props.setProperty("mail.to", "gguo1@e.ntu.edu.sg");

		props.setProperty("mail.subject", "Program Notifier from Gmail");

		props.setProperty("mail.text", "Program was finished @" + Dates.now());
