「java编写时间提醒」java时间显示

博主:adminadmin 2023-03-17 22:26:10 337

本篇文章给大家谈谈java编写时间提醒,以及java时间显示对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

Java如何实现定时提醒功能

在body的noload里面有个setInterval定时器:

body style="height: 700px; overflow: hidden;" onload="setInterval('timedAlert()',10000)"

js脚本:

//ajax判断是否有提醒数据

function timedAlert(){

$.ajax({

type: "get",

url: "${basePath}/plugins/km/headlink/checkNoteCount.jspx",

dataType: "text",

cache: false,

success: function(data){

alert(data);

if(data=='0'){

alert(1);//你的代码

}else{

alert(22);

}

}

});

}

便签吧?大概的思路,希望对你有帮助!

java怎么实现日历日程提醒

用数据库吧

首先,保存事件的表mem

create table mem(

mid varchar(10) not null prmary key,

mdate date not null,

mem varchar(255),

userid varchar(20) not null

)

-- 如果是简单的单用户的话可以不要这个。

-- 然后用户登录的时候你就可以使用select mem from mem where userid='当前用户' and m_date='今天的日期'就可以查询出这个用户添加的日程提醒了。

JAVA里怎么实现,在某个固定的日期进行提醒?

用Java是可以这样实现的。使用Java自带的定时器 Timer 类 写一个定时器。把该类写好编译后。写一个 bat 文件(批处理文件)调用该类。然后将该bat 文件 注册到操作系统服务中,使得开机自启动。这样每次开机后,系统都会调用该服务-执行批处理文件-执行该定时器。这样到了定时器中指定的时间后,就会有提醒。至于如何提醒,可以在定时器中定义。

每天固定时间在桌面右下角弹出提示信息窗口的java程序

一个关于定时提醒的弹窗例子,还不是很成熟,仅供参考

//主窗口界面设计

public class TestButtons {

JFrame frame = new JFrame("提醒");

JButton jButton = new JButton("开始运行"); //按钮

JCheckBox checkBox = new JCheckBox("早上提醒"); //复选按钮

JCheckBox checkBox1 = new JCheckBox("晚上提醒"); //复选按钮

JLabel label = new JLabel("Ready to run."); //静态文本

//构造函数

public TestButtons() {

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.getContentPane().setLayout(new java.awt.FlowLayout());

//为按钮添加动作监听器

jButton.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent ae) {

//按钮事件处理程序

label.setText("Thread keep running.");

int i=Timetorun()*1000;

try {

Thread.sleep(i);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

JFrame parent = new JFrame();

JOptionPane.showMessageDialog(parent, "该干啥了。");

}

});

//早上提醒 复选框处理程序

checkBox.addItemListener(new ItemListener() {

public void itemStateChanged(ItemEvent e) {

JCheckBox cb = (JCheckBox) e.getSource();

label.setText("Selected Check Box is " + cb.isSelected());

}

});

//晚上提醒 复选框处理程序

checkBox1.addItemListener(new ItemListener() {

public void itemStateChanged(ItemEvent e) {

JCheckBox cb = (JCheckBox) e.getSource();

label.setText("Selected Check Box is " + cb.isSelected());

}

});

//添加组件到容器

frame.getContentPane().add(jButton);

frame.getContentPane().add(checkBox);

frame.getContentPane().add(checkBox1);

frame.getContentPane().add(label);

frame.setSize(200, 250);

}

public void show() {

frame.show();

}

//主处理函数

public static void main(String[] args) {

TestButtons tb = new TestButtons();

tb.show();

}

//时间处理函数

public static int Timetorun(){

//获取系统当前时间

Calendar cal=Calendar.getInstance();

int nowhour=cal.get(Calendar.HOUR_OF_DAY);

int nowminite=cal.get(Calendar.MINUTE);

int nowweek=cal.get(Calendar.DAY_OF_WEEK);

System.out.println(nowhour+"");

System.out.println(nowminite+"");

System.out.println(nowweek+"");

int dehour=0;

int deminite=0;

//获取延迟时间

if(nowweek==2 || nowweek==3 || nowweek==5){

if(nowminite=30 nowhour=20){

deminite=30-nowminite;

dehour=20-nowhour;

}

else if(nowminite30 nowhour=20){

deminite=90-nowminite;

dehour=19-nowhour;

}

else if (nowminite=30 nowhour20) {

deminite=30-nowminite;

dehour=44-nowhour;

}

else {

deminite=90-nowminite;

dehour=43-nowhour;

}}

else if(nowweek==4 || nowweek==6 || nowweek==7 || nowweek==1){

if(nowminite=30 nowhour=17){

deminite=30-nowminite;

dehour=17-nowhour;

}

else if(nowminite30 nowhour=17){

deminite=90-nowminite;

dehour=16-nowhour;

}

else if (nowminite=30 nowhour17) {

deminite=30-nowminite;

dehour=41-nowhour;

}

else {

deminite=90-nowminite;

dehour=40-nowhour;

}

}

//延迟时间为K分钟

int k= dehour*60 + deminite;

return k;

}

}

关于java编写时间提醒和java时间显示的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。