Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SalidasAutomaticas
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Billy Larru
SalidasAutomaticas
Commits
54f2e783
Commit
54f2e783
authored
Sep 01, 2018
by
Billy Larru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asdfadsf
parent
af43c1b4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
49 deletions
+88
-49
Main.java
src/salidasautomaticas/main/Main.java
+33
-22
Metodos.java
src/salidasautomaticas/util/Metodos.java
+55
-27
No files found.
src/salidasautomaticas/main/Main.java
View file @
54f2e783
...
@@ -17,27 +17,38 @@ import salidasautomaticas.util.Metodos;
...
@@ -17,27 +17,38 @@ import salidasautomaticas.util.Metodos;
public
class
Main
{
public
class
Main
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
Main
.
class
);
private
static
final
Logger
log
=
LogManager
.
getLogger
(
Main
.
class
);
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
setLogLevel
(
Level
.
TRACE
);
//DESARROLLO
// setLogLevel(Level.TRACE);//DESARROLLO
// setLogLevel(Level.INFO);//PRODUCCION
//// setLogLevel(Level.INFO);//PRODUCCION
log
.
info
(
"Inicializando programa [Salidas Automaticas]..."
);
// log.info("Inicializando programa [Salidas Automaticas]...");
//
Date
horaInicio
=
Metodos
.
getHoraEjecucion
(
"11:30"
);
// Date horaInicio = Metodos.getHoraEjecucion("11:30");
int
periodo
=
86400000
;
//El codigo se ejecutará cada 24h, 86400000 representa 24h en milisegundos
// int periodo = 86400000;//El codigo se ejecutará cada 24h, 86400000 representa 24h en milisegundos
//
TimerTask
task
=
new
ProgramarSalidasTask
();
// TimerTask task = new ProgramarSalidasTask();
Timer
timer
=
new
Timer
();
// Timer timer = new Timer();
timer
.
schedule
(
task
,
horaInicio
,
periodo
);
// timer.schedule(task, horaInicio, periodo);
}
int
i
=
1
;
private
static
void
setLogLevel
(
Level
l
)
{
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
log
.
info
(
"Setting log level to "
+
l
.
name
());
sss
(
i
++);
LoggerContext
ctx
=
(
LoggerContext
)
LogManager
.
getContext
(
false
);
Configuration
conf
=
ctx
.
getConfiguration
();
}
conf
.
getLoggerConfig
(
LogManager
.
ROOT_LOGGER_NAME
).
setLevel
(
l
);
ctx
.
updateLoggers
(
conf
);
}
}
private
static
void
setLogLevel
(
Level
l
)
{
log
.
info
(
"Setting log level to "
+
l
.
name
());
LoggerContext
ctx
=
(
LoggerContext
)
LogManager
.
getContext
(
false
);
Configuration
conf
=
ctx
.
getConfiguration
();
conf
.
getLoggerConfig
(
LogManager
.
ROOT_LOGGER_NAME
).
setLevel
(
l
);
ctx
.
updateLoggers
(
conf
);
}
private
static
void
sss
(
int
numero
)
{
System
.
out
.
println
(
"valor en sss="
+
numero
);
}
}
}
src/salidasautomaticas/util/Metodos.java
View file @
54f2e783
...
@@ -7,37 +7,65 @@ package salidasautomaticas.util;
...
@@ -7,37 +7,65 @@ package salidasautomaticas.util;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Date
;
import
org.json.JSONArray
;
/**
/**
*
*
* @author sistem19user
* @author sistem19user
*/
*/
public
class
Metodos
{
public
class
Metodos
{
/**
/**
* Devuelve un objeto Date con la fecha de hoy y con la hora
* Devuelve un objeto Date con la fecha de hoy y con la hora que le pasamos
* que le pasamos como parametro(en formato hh:mm en 24 horas).
* como parametro(en formato hh:mm en 24 horas).
*
*
* @param horaEjecucion hora que se va a setear al Date del dia de hoy.
* @param horaEjecucion hora que se va a setear al Date del dia de hoy.
* @return
* @return
*/
*/
public
static
Date
getHoraEjecucion
(
String
horaEjecucion
)
{
public
static
Date
getHoraEjecucion
(
String
horaEjecucion
)
{
Date
date
=
new
Date
(
System
.
currentTimeMillis
());
Date
date
=
new
Date
(
System
.
currentTimeMillis
());
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
calendar
.
setTime
(
date
);
String
[]
splitHoraSalida
=
horaEjecucion
.
split
(
":"
);
String
[]
splitHoraSalida
=
horaEjecucion
.
split
(
":"
);
int
hora
=
Integer
.
parseInt
(
splitHoraSalida
[
0
]);
int
hora
=
Integer
.
parseInt
(
splitHoraSalida
[
0
]);
int
minuto
=
Integer
.
parseInt
(
splitHoraSalida
[
1
]);
int
minuto
=
Integer
.
parseInt
(
splitHoraSalida
[
1
]);
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
hora
);
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
hora
);
calendar
.
set
(
Calendar
.
MINUTE
,
minuto
);
calendar
.
set
(
Calendar
.
MINUTE
,
minuto
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
date
=
calendar
.
getTime
();
date
=
calendar
.
getTime
();
return
date
;
return
date
;
}
}
public
static
void
main
(
String
[]
args
)
{
JSONArray
array
=
new
JSONArray
();
array
.
put
(
Integer
.
class
)
.
put
(
String
.
class
)
.
put
(
Boolean
.
class
);
f
(
Integer
.
class
);
// System.out.println(array);
// ss(array);
// System.out.println(array.get(0));
// System.out.println(array);
}
private
static
void
f
(
Class
c
)
{
System
.
out
.
println
(
c
.
getName
());
switch
(
c
.
getName
())
{
case
"java.lang.Integer"
:
System
.
out
.
println
(
"entero"
);
}
}
private
static
void
ss
(
JSONArray
arr
)
{
System
.
out
.
println
(
arr
.
get
(
0
));
arr
.
put
(
0
,
1
);
arr
.
put
(
1
,
"hello"
);
arr
.
put
(
2
,
true
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment