Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

code

Ads

 
 

Share on Google+Share on Google+

sayantp
code
1 Answer(s)      4 years and 10 months ago
Posted in : Date-Calendar

hi

I need help in creating a java code that reminds user on a particular date about their festival. i have no clue of how to do it.. am looking forward to seek help from you.

Ads
View Answers

June 5, 2013 at 5:09 PM


http://www.roseindia.net/answers/viewqa/Date-Calendar/27893-code-.html

Hi friend,

You may do it with using Timer, TimerTask, Task, Date, and Calendar class. Using Date and/or Calendar class you can specify the date to reminder and using Task, Timer and TimerTask you can schedule your task and timer.

package net.roseindia.schedular;
import java.io.IOException;
import java.util.Calendar;
import java.util.TimerTask;
import java.util.Date;
import java.util.Timer;
import java.util.concurrent.TimeUnit;

import javax.swing.JOptionPane;

class Task extends TimerTask {

    public void run() {

            JOptionPane.showMessageDialog(null, "Today is your festival.","Festival",
                    JOptionPane.INFORMATION_MESSAGE);       
    }
}

public class JavaSchedular {
    public static void main(String args[]) throws InterruptedException {

        Timer timer = new Timer();
        Date date = new Date();
        int month = java.util.Calendar.getInstance().get(java.util.Calendar.MONTH);
        int year = java.util.Calendar.getInstance().get(java.util.Calendar.YEAR);;
        java.util.Calendar cal = java.util.Calendar.getInstance();
        cal.set(year, month, 5);
        long time = System.currentTimeMillis();
        Date millsDate = new Date(time);        
        System.out.println(cal.getTime());
        date = cal.getTime();
        System.out.println(System.currentTimeMillis());
        Task task = new Task();
        if(date.equals(millsDate))
        {
            timer.schedule(task, date ,TimeUnit.SECONDS.toMillis(2));
        }else
        {
            JOptionPane.showMessageDialog(null, "Date Not Matched.","Date",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    }
}

Thanks.


Ads









Related Tutorials/Questions & Answers:
Code
Code  code for connecting c lang to database
code
code    how to write this in java
Advertisements
code
code  code for android sample program
code for this is
code for this is  a b c d c b a a b c c b a a b b a a a code
code
code  please provide code for custom tags.by using currdate tag we need to get current date?please give me code
code
code   hi I need help in creating a java code that reminds user on a particular date about their festival. i have no clue of how to do it.. am looking forward to seek help from you
code
the correct code for a program.The output of the program is listed below...: {Block 5} ADDRESS-3: {San Juan} POST CODE:{6745} ENTER CODE (XX TO stop) CODE:{FF1} QUANTITY:{2} CODE:{TR4} QUANTITY:{1} CODE:XX INVOICE FOR YOUR ORDER Harry
code
code to create the RMI client on the local machine: import java.rmi.*; public... : "+e); } } } However, when the preceding code is executed it results... the correct code
code
code  i have four textboxes.whenever i click on up,down,left or down arrows then the cursor move to another textbox based on the key pressed.i want code for this in javascript
code
line of code to print the amount he should be paid as allowance
code
code  write a program to encrypt and decrypt the cipher text "adfgvx"   Hi Friend, Try the following code: import java.security.*; import javax.crypto.*; import javax.crypto.spec.*; import java.io.
JAVA code For
JAVA code For   JAVA code For "Traffic signals Identification for vehicles
example code
example code  code for displaying a list from another class on a midlet
stegnography code
stegnography code  code for the digital stegnographic technique for the encryption and decryption of image
jsp code
jsp code  what are the jsp code for view page in online journal
c code
c code  c code for this formula x=(y-0.22z-072)4; where y=7.32 x=3.1 then ans x=23.9 end code for this   c code for this formula x=(y-0.22z-072)4; where y=7.32 x=3.1 then ans x=23.9 can any one end code
Source code
Source code  source code of html to create a user login page
c code
c code  c code for this formula x=(y-0.22z-072)4; where y=7.32 x=3.1 then ans x=23.9 end code
Code for a triangle.....
Code for a triangle.....   1 1 5 1 1 5 25 5 1 What is the source Code for above output
Code for Pattern
Code for Pattern   * *** * * Please write the code of above program and please do not use in this string tokennizer, string buffer etc i mean to say that please use very simple method
Code for Pattern
Code for Pattern   * * * * * * * * Please write the code of above program and please do not use in this string tokennizer, string buffer etc i mean to say that please use very simple method
Code for Pattern
Code for Pattern   * * * * * * * * * * * Please write the code of above program and please do not use in this string tokennizer, string buffer etc i mean to say that please use very simple method
JSF code
need jsf code that will populate combo box values from the database  Hi, i'm new on JSf,I need jsf code that will populate combo box values from the database when the form runs
HTML code
HTML code  How do I keep people from stealing my source code and/or images
java code
java code  what is the code to turn off my pc through java program
code - Struts
code  How to write the code for multiple actions for many submit buttons.  use dispatch action