自动过期日期 [英] Auto Expire date

查看:97
本文介绍了自动过期日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要根据日期更改来更改行

我想要在jsp中自动过期日期的代码并更改行

I wnat to change lines as per the date change

i want code in jsp for auto expire date & change the line

推荐答案

我不确定您的意思是什么,如果您需要运行一段代码每天(计算机日期一经更改),我可能就会为您提供答案:)

该示例在C#中进行,但是java非常相似,因此我相信您将能够对其进行翻译.

I''m not sure what you mean exactly, if you need to run a piece of code every day (as soon as the computers date changes) then I might have an answer for you :)

The example is in C# but java is very similar so I''m sure you''ll be able to translate it.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleTest
{
    class Program
    {
        static System.Timers.Timer timer = new System.Timers.Timer(500);
        static DateTime LastDateExecuted = DateTime.Now;

        static void Main(string[] args)
        {
            timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
            timer.Start();

            Console.ReadLine();
        }

        static void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (LastDateExecuted.Date != DateTime.Now.Date)
            {
                //
                // The date changed, do something
                DoSomeWork();

                //
                // Set the last date executed variable for this days checks
                LastDateExecuted = DateTime.Now.Date;
            }
        }

        private static void DoSomeWork()
        {
            Console.WriteLine("The date changed");
        }
    }
}



希望这对您有所帮助:thumbsup:



Hope this helps you :thumbsup:


这篇关于自动过期日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆