๋ฐ์ํ
์๋ฐ ํ์ด๋จธ ๊ธฐ๋ฅ์ ์ฌ์ฉํด์ ์ ํด์ง ์๊ฐ๊ฐ๊ฒฉ์ผ๋ก ํ๋ก๊ทธ๋จ์ด ์คํ๋๊ณ
๋ฐ์ดํฐ๊ฐ ์ ๋ฐ์ดํธ ๋ ์ ์๊ฒ ๋ง๋ค์์ด์!!
1000*5 5์ด
1000*60 1๋ถ
1000*60*60 1์๊ฐ
1000*60*60*24 1์ผ
//ํ๋ก์ ํธ ํต์ผ๋ก ์ฌ๋ ค๋ ๊นํ๋ธ ์ฃผ์์ ๋๋ค.
๋ค๋ฅธ ๋ด์ฉ์ด ๊ถ๊ธํ์๋ค๋ฉด ํ์ธ ํด ์ฃผ์ธ์.
github.com/Joowon0220/weather.git
package com.weather03.mvc;
import java.io.IOException;
import java.util.Calendar;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import org.json.simple.parser.ParseException;
public class weatherControl extends TimerTask {
public void run() {
Calendar date = Calendar.getInstance();
String stamp = date.get(Calendar.HOUR_OF_DAY) + ":" + date.get(Calendar.MINUTE) + ":"
+ date.get(Calendar.SECOND) + ":" + date.get(Calendar.MILLISECOND);
System.out.println(stamp + " " + "Generating report");
// List<VillageWeather> datalist = new List<VillageWeather>;
VillageWeatherJson vlist = new VillageWeatherJson();
// ๊ธฐ์๋ฐ์ดํฐ๋ฅผ JSON์ arrayList ํํ๋ก ๋ฐ์ VillageWeather์ ์ ์ฅ
List<VillageWeather> vw;
try {
vw = vlist.getVillageWeather();
VillageWeatherDAO vwDao = new VillageWeatherDAO();
vwDao.insertVillageWeather(vw);
} catch (IOException | ParseException | ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ ์์ ๊ด๋ จํ๋๊ฐ์ฒด๋ฅผ ๋ง๋ค๊ณ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์
๋ ฅ
}
public static void main(String[] args) {
Timer timer = new Timer();
Calendar date = Calendar.getInstance();
date.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY
);
date.set(Calendar.HOUR, 0);
date.set(Calendar.MINUTE, 0);
date.set(Calendar.SECOND, 0);
date.set(Calendar.MILLISECOND, 0);
// Schedule to run every Sunday in midnight
timer.schedule(new weatherControl(), date.getTime(),
// 1000 * 5
// 1000 * 60 * 60 * 24
1000 * 60* 60);
}
}
๋ฐ์ํ
'l ๐ค ์ฝ๋ l' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
์ดํด๋ฆฝ์ค mssql ์ฐ๋ํ๊ธฐ (0) | 2020.05.21 |
---|---|
์ดํด๋ฆฝ์ค์์ ms-sql ์ ์ํ๊ธฐ (0) | 2020.05.21 |
๊ธฐ์์ฒญ ๋ ์จapi JSON์ผ๋ก ๋ฐ์์์ ํ์ฑํ๊ธฐ (์๋ถ๋ฌ์์ง๋!! ์๋ฌํด๊ฒฐ) (0) | 2020.05.21 |
๊ธฐ์์ฒญ api ๋ฐ์์ค๋ ๋ฒ (์ธ์ฆํค ๋ฐ๊ธ๋ฐ๊ธฐ) (0) | 2020.05.21 |
๊ธฐ์์ฒญ ๋ ์จ api ๋ฐ์์์ db์ ์ ์ฅํ๊ธฐ (sql) (0) | 2020.05.21 |
๋๊ธ