Thanks my programming . I solve this problem. Now I can calculate the time difference .
I want to remember this code. I am really really excited now.
------------------------------------------------------------------------------------------------------------------------
I want to remember this code. I am really really excited now.
------------------------------------------------------------------------------------------------------------------------
button1 = (Button) findViewById(R.id.setalarm);
tp = (TimePicker) findViewById(R.id.tp);
// button click to get time from time-picker
button1.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View view) {
Calendar calendar = Calendar.getInstance();
calendar.set(
calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH),
tp.getHour(),
tp.getMinute(),
0
);
Intent intent = new Intent(MainActivity.this, Notification_receiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 100, intent, PendingIntent.FLAG_UPDATE_CURRENT);
// this time is for reminder---
long value = calendar.getTimeInMillis();
System.out.println(value);
// to get present time---
java.util.Calendar time = java.util.Calendar.getInstance();
long present_time = time.getTimeInMillis();
System.out.println(present_time);
long difference = value - present_time;
System.out.println(difference);
-------------------------------------------------------------------------------------------------------------------------------------------------------