package other_package;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

public class MyTest5 
{
	public static void main(String[] args) throws ParseException 
	{
		
		
		//OR
		String userId = "288";
		String password = "123456";

		//Send Method
		String sendMethod = "simpleMsg";

		//Message type text/unicode/flash
		String msgType = "text";

		//Multiple mobiles numbers separated by comma
		String mobile = "9982311326";
		//Your approved sender id
		String senderId = "WENEWS";
		//Your message to terminate, URLEncode the content
		String msg = "TEST FROM GARG WEB INFOTECH";
		//response format
		String format = "json";
		//Your apikey key
				String apiKey = "55CC6DF988C996";
		//Prepare Url
		URLConnection myURLConnection=null;
		URL myURL=null;
		BufferedReader reader=null;

		//URL encode message
		String urlencodedmsg=URLEncoder.encode(msg);

		//API End Point
		String mainUrl="http://sms.digitalhelpline.in/app/smsapi/index.php?";

		//API Paramters
		StringBuilder sendSmsData= new StringBuilder(mainUrl);
		sendSmsData.append("key="+apiKey);
		sendSmsData.append("&routeid="+userId);
		//sendSmsData.append("&password="+password);
		//sendSmsData.append("&sendMethod="+sendMethod);
		sendSmsData.append("&Type="+msgType);
		sendSmsData.append("&contacts="+mobile);
		sendSmsData.append("&senderid="+senderId);
		sendSmsData.append("&msg="+urlencodedmsg);
		sendSmsData.append("&format="+format);
		//final string
		mainUrl = sendSmsData.toString();
		try
		{
			System.out.println(mainUrl);
		//prepare connection
		myURL = new URL(mainUrl);
		myURLConnection = myURL.openConnection();
		myURLConnection.connect();
		reader= new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));
		//reading response
		String response;
		while ((response = reader.readLine()) != null)
		//print response
		System.out.println(response);

		//finally close connection
		reader.close();
		}
		catch (IOException e)
		{
		e.printStackTrace();
		}
		
		
		/*String value="15";
		
		System.out.println("Double Parse: "+Double.parseDouble(value));
		System.out.println("Double Value: "+Double.valueOf(value));
		System.out.println("Integer value: "+Integer.valueOf(value));
		System.out.println("Integer Parse: "+Integer.parseInt(value));*/
		
		
		/*Date dt=new Date();
		dt.setHours(0);
		dt.setMinutes(0);
		dt.setSeconds(0);
		String sDate="16-04-2019";
		
		SimpleDateFormat f = new SimpleDateFormat("dd-MM-yyyy");
		Date startDate=f.parse(sDate);
		
		if(dt.before(startDate))
		{
			System.out.println(dt);
			System.out.println("before");
			System.out.println(sDate);
		}
		else
		{
			System.out.println("elseeee");
		}
		
		if(startDate.after(dt))
		{
			System.out.println("after");
		}
		
		if(startDate.equals(dt))
		{
			System.out.println("equal");
		}
		*/
		
		/*double val=-6.5;
		System.out.println(Math.abs(val));*/
		
		/*Date dt=new Date();
		 
		Date dt1=new Date(), dt2=new Date();
		dt1.setDate(dt.getDate()-6);
		dt2.setDate(dt.getDate()+6);
		 System.out.println(dt);
		 System.out.println(dt1);
	     System.out.println(dt2);*/
		 
		 
		/*double installment_amount=0, terms=365, interest=9.5, ins=100;
		int i=1;
		for (double m = 1; m <=terms; m++) 
		{
			double tt = ins* (Math.pow(1+(interest / 100), m/365));
			//System.out.println(terms+"tt: "+tt+"***"+m+"========"+interest / 100);
			if (m != 0) 
			{
				installment_amount=installment_amount+ tt;
				
				if(i==90)
				{
					ins=installment_amount/90;
					System.out.println("90 Days "+ins);
				}
				if(i==180)
				{
					ins=installment_amount/180;
					System.out.println("180 Days "+ins);
				}
				if(i==270)
				{
					ins=installment_amount/270;
					System.out.println("270 Days "+ins);
				}
				if(i==360)
				{
					ins=installment_amount/360;
					System.out.println("360 Days "+ins);
				}
				i++;
				System.out.println(installment_amount);
			}
		}
		Math.round(installment_amount);
		*/
		
		/*Timestamp tt=new Timestamp(new Date().getTime());
		String dt=String.valueOf(tt);
		
		String dte=dt.substring(0, 10);
		String tm=dt.substring(11, 19);
		
		
		
		System.out.println(dte+"==="+tm);*/
		
		
		/*Date startDate=new Date(); 
		Date endDate=new Date(); 
		
		endDate.setDate(endDate.getDate()+3);
		System.out.println(startDate+"========"+endDate);
		while(startDate.before(endDate) || startDate.equals(endDate))
		{
			System.out.println("hiiiiiiiii "+startDate);
			startDate.setDate(startDate.getDate()+1);
		}
		
		
		SimpleDateFormat dateObj=new SimpleDateFormat("ddMMyyyy");
		System.out.println(startDate.toLocaleString());
		
		Calendar c = Calendar.getInstance();
		c.setTime(startDate);
		int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
		System.out.println(new SimpleDateFormat("EE").format(startDate));
		System.out.println(dateObj.format(startDate));*/
	}
}
