Package es.gob.afirma.mreport.utils
Class UtilsTime
- java.lang.Object
-
- es.gob.afirma.mreport.utils.UtilsTime
-
public class UtilsTime extends java.lang.ObjectClass that provides methods for managing dates.
Project:Library for the integration with the services of @Firma, eVisor and TS@.
- Version:
- 1.0, 25/08/2020.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringFORMATO_COMPLETOConstant attribute that represents the date formatyyyy-MM-dd EEE HH:mm:ss ZZZZ.static java.lang.StringFORMATO_COMPLETO_ADICIONALConstant attribute that represents the date format"yyyy/MM/dd EEE hh:mm:ss zzzz".static java.lang.StringFORMATO_FECHAConstant attribute that represents the date formatyyyy-MM-dd.static java.lang.StringFORMATO_FECHA_BAJAConstant attribute that represents the date formatdd_MM_yyyy.static java.lang.StringFORMATO_FECHA_BARRASConstant attribute that represents the date format"dd/MM/yyyy/HH/mm/ss".static java.lang.StringFORMATO_FECHA_CORTOConstant attribute that represents the date formatdd/MM/yyyy.static java.lang.StringFORMATO_FECHA_ESTANDARConstant attribute that represents the date format"dd/MM/yyyy HH:mm:ss".static java.lang.StringFORMATO_FECHA_ESTANDAR_ADICIONALConstant attribute that represents the date format"dd/MM/yyyy HH:mm:ss.SSS".static java.lang.StringFORMATO_FECHA_HORAConstant attribute that represents the date formatyyyy-MM-dd HH:mm:ss.static java.lang.StringFORMATO_FECHA_HORA_ADICIONALConstant attribute that represents the date format"yyyy-MM-dd'T'HHmmssZ".static java.lang.StringFORMATO_FECHA_HORA_COMPLETAConstant attribute that represents the date format"yyyy-MM-dd HH:mm:ss,SSS".static java.lang.StringFORMATO_FECHA_HORA_MINUTOSConstant attribute that represents the date format"dd-MMM-yyyy HH:mm".static java.lang.StringFORMATO_FECHA_HORA_SEGUNDOSConstant attribute that represents the date format"dd-MM-yy_HH-mm-ss".static java.lang.StringFORMATO_FECHA_INVERTIDOConstant attribute that represents the date format"dd-MM-yyyy".static java.lang.StringFORMATO_FECHA_JUNTAConstant attribute that represents the date formatyyyyMMddHHmmss.static java.lang.StringFORMATO_FECHA_JUNTA_ADICIONALConstant attribute that represents the date format"yyyyMMddHHmmss.SZ".static java.lang.StringFORMATO_FECHA_JUNTA_CORTAConstant attribute that represents the date formatyyyyMMdd.static java.lang.StringFORMATO_FECHA_UTCConstant attribute that represents the date format"yyyy-MM-dd'T'HH:mm:ss.SSS".static java.lang.StringFORMATO_HORAConstant attribute that represents the date formatHH:mm:ss.static java.lang.StringFORMATO_SEMICOMPLETOConstant attribute that represents the date format"yyyy-MM-dd HH:mm:ss ZZZZ".
-
Constructor Summary
Constructors Constructor Description UtilsTime()Constructor method for the class UtilsTime.java.UtilsTime(java.lang.String timezone)Constructor method for the class UtilsTime.java.UtilsTime(java.lang.String fechaStr, java.lang.String formato)Constructor method for the class UtilsTime.java.UtilsTime(java.util.Calendar c)Constructor method for the class UtilsTime.java.UtilsTime(java.util.Date pFecha)Constructor method for the class UtilsTime.java.UtilsTime(java.util.TimeZone t)Constructor method for the class UtilsTime.java.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.DateconvierteFecha(java.lang.String fecha, java.lang.String patron)Method that obtains a date from a string using a determined pattern.java.util.DategetFecha()Gets the value of the attributefecha.static java.lang.StringgetFechaMasNDias(java.lang.String fechaEnt, int diasAdd)Method that adds a number of days to certain date.static java.lang.StringgetFechaSistema(java.lang.String formato)Method that obtains the current date and hour of the system.static java.util.DategetUTCDate(java.lang.String utcDate)Method that obtains a date from a string withUTCformat.static java.lang.StringmodificarFormato(java.lang.String fecha, java.lang.String formatoOriginal, java.lang.String nuevoFormato)Method that modifies the format of a date.voidsetFecha(java.util.Date pFecha)Sets the value of the attributefecha.voidsumar(int numDias)Method that adds a number of days to the date.java.lang.StringsumarDias(int numDias)Method that adds a number of days to the system date.java.lang.StringtoString()java.lang.StringtoString(java.lang.String formato)Method that obtains a string with the value of the date for certain format.java.lang.StringtoString(java.text.SimpleDateFormat formador)Method that obtains a string with the value of the date for certain format.java.lang.StringtoUTCString()Method that obtains a string which represents the date onUTCformat.
-
-
-
Field Detail
-
FORMATO_COMPLETO
public static final java.lang.String FORMATO_COMPLETO
Constant attribute that represents the date formatyyyy-MM-dd EEE HH:mm:ss ZZZZ.- See Also:
- Constant Field Values
-
FORMATO_FECHA
public static final java.lang.String FORMATO_FECHA
Constant attribute that represents the date formatyyyy-MM-dd.- See Also:
- Constant Field Values
-
FORMATO_HORA
public static final java.lang.String FORMATO_HORA
Constant attribute that represents the date formatHH:mm:ss.- See Also:
- Constant Field Values
-
FORMATO_FECHA_HORA
public static final java.lang.String FORMATO_FECHA_HORA
Constant attribute that represents the date formatyyyy-MM-dd HH:mm:ss.- See Also:
- Constant Field Values
-
FORMATO_FECHA_CORTO
public static final java.lang.String FORMATO_FECHA_CORTO
Constant attribute that represents the date formatdd/MM/yyyy.- See Also:
- Constant Field Values
-
FORMATO_FECHA_JUNTA
public static final java.lang.String FORMATO_FECHA_JUNTA
Constant attribute that represents the date formatyyyyMMddHHmmss.- See Also:
- Constant Field Values
-
FORMATO_FECHA_JUNTA_CORTA
public static final java.lang.String FORMATO_FECHA_JUNTA_CORTA
Constant attribute that represents the date formatyyyyMMdd.- See Also:
- Constant Field Values
-
FORMATO_FECHA_BAJA
public static final java.lang.String FORMATO_FECHA_BAJA
Constant attribute that represents the date formatdd_MM_yyyy.- See Also:
- Constant Field Values
-
FORMATO_FECHA_ESTANDAR
public static final java.lang.String FORMATO_FECHA_ESTANDAR
Constant attribute that represents the date format"dd/MM/yyyy HH:mm:ss".- See Also:
- Constant Field Values
-
FORMATO_FECHA_BARRAS
public static final java.lang.String FORMATO_FECHA_BARRAS
Constant attribute that represents the date format"dd/MM/yyyy/HH/mm/ss".- See Also:
- Constant Field Values
-
FORMATO_FECHA_JUNTA_ADICIONAL
public static final java.lang.String FORMATO_FECHA_JUNTA_ADICIONAL
Constant attribute that represents the date format"yyyyMMddHHmmss.SZ".- See Also:
- Constant Field Values
-
FORMATO_FECHA_HORA_ADICIONAL
public static final java.lang.String FORMATO_FECHA_HORA_ADICIONAL
Constant attribute that represents the date format"yyyy-MM-dd'T'HHmmssZ".- See Also:
- Constant Field Values
-
FORMATO_FECHA_HORA_COMPLETA
public static final java.lang.String FORMATO_FECHA_HORA_COMPLETA
Constant attribute that represents the date format"yyyy-MM-dd HH:mm:ss,SSS".- See Also:
- Constant Field Values
-
FORMATO_FECHA_INVERTIDO
public static final java.lang.String FORMATO_FECHA_INVERTIDO
Constant attribute that represents the date format"dd-MM-yyyy".- See Also:
- Constant Field Values
-
FORMATO_FECHA_ESTANDAR_ADICIONAL
public static final java.lang.String FORMATO_FECHA_ESTANDAR_ADICIONAL
Constant attribute that represents the date format"dd/MM/yyyy HH:mm:ss.SSS".- See Also:
- Constant Field Values
-
FORMATO_FECHA_HORA_MINUTOS
public static final java.lang.String FORMATO_FECHA_HORA_MINUTOS
Constant attribute that represents the date format"dd-MMM-yyyy HH:mm".- See Also:
- Constant Field Values
-
FORMATO_SEMICOMPLETO
public static final java.lang.String FORMATO_SEMICOMPLETO
Constant attribute that represents the date format"yyyy-MM-dd HH:mm:ss ZZZZ".- See Also:
- Constant Field Values
-
FORMATO_FECHA_UTC
public static final java.lang.String FORMATO_FECHA_UTC
Constant attribute that represents the date format"yyyy-MM-dd'T'HH:mm:ss.SSS".- See Also:
- Constant Field Values
-
FORMATO_COMPLETO_ADICIONAL
public static final java.lang.String FORMATO_COMPLETO_ADICIONAL
Constant attribute that represents the date format"yyyy/MM/dd EEE hh:mm:ss zzzz".- See Also:
- Constant Field Values
-
FORMATO_FECHA_HORA_SEGUNDOS
public static final java.lang.String FORMATO_FECHA_HORA_SEGUNDOS
Constant attribute that represents the date format"dd-MM-yy_HH-mm-ss".- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UtilsTime
public UtilsTime()
Constructor method for the class UtilsTime.java.
-
UtilsTime
public UtilsTime(java.util.Date pFecha)
Constructor method for the class UtilsTime.java.- Parameters:
pFecha- Parameter that represents the value of the date.
-
UtilsTime
public UtilsTime(java.util.Calendar c)
Constructor method for the class UtilsTime.java.- Parameters:
c- Parameter that represents the object to set the value of the date and the time zone offset.
-
UtilsTime
public UtilsTime(java.util.TimeZone t)
Constructor method for the class UtilsTime.java.- Parameters:
t- Parameter that represents the time zone offset.
-
UtilsTime
public UtilsTime(java.lang.String timezone)
Constructor method for the class UtilsTime.java.- Parameters:
timezone- Parameter that represents the identifier for the time zone offset.
-
UtilsTime
public UtilsTime(java.lang.String fechaStr, java.lang.String formato) throws java.text.ParseExceptionConstructor method for the class UtilsTime.java.- Parameters:
fechaStr- Parameter that represents the value of the date.formato- Parameter that represents the format used for the date.- Throws:
java.text.ParseException- If the method fails.
-
-
Method Detail
-
toString
public java.lang.String toString(java.lang.String formato)
Method that obtains a string with the value of the date for certain format.- Parameters:
formato- Parameter that represents the format to apply for the date.- Returns:
- a string with the value of the date for certain format.
-
toString
public java.lang.String toString(java.text.SimpleDateFormat formador)
Method that obtains a string with the value of the date for certain format.- Parameters:
formador- Parameter that represents the concrete object for formatting and parsing the date in a locale-sensitive manner.- Returns:
- a string with the value of the date for certain format.
-
toUTCString
public java.lang.String toUTCString()
Method that obtains a string which represents the date onUTCformat.- Returns:
- the string on
UTCformat.
-
getUTCDate
public static java.util.Date getUTCDate(java.lang.String utcDate) throws java.text.ParseExceptionMethod that obtains a date from a string withUTCformat.- Parameters:
utcDate- Parameter that represents the string withUTCformat.- Returns:
- the date.
- Throws:
java.text.ParseException- If the method fails.
-
getFechaSistema
public static java.lang.String getFechaSistema(java.lang.String formato)
Method that obtains the current date and hour of the system.- Parameters:
formato- Parameter that represents the format used to obtain the date.- Returns:
- the current date and hour of the system.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
getFecha
public java.util.Date getFecha()
Gets the value of the attributefecha.- Returns:
- the value of the attribute
fecha.
-
setFecha
public void setFecha(java.util.Date pFecha)
Sets the value of the attributefecha.- Parameters:
pFecha- The value for the attributefecha.
-
sumar
public void sumar(int numDias)
Method that adds a number of days to the date.- Parameters:
numDias- Parameter that represents the number of days to add.
-
modificarFormato
public static java.lang.String modificarFormato(java.lang.String fecha, java.lang.String formatoOriginal, java.lang.String nuevoFormato) throws java.text.ParseExceptionMethod that modifies the format of a date.- Parameters:
fecha- Parameter that represents the date.formatoOriginal- Parameter that represents the original format.nuevoFormato- Parameter that represents the new format.- Returns:
- a string that represents the date with the new format.
- Throws:
java.text.ParseException- If the method fails.
-
sumarDias
public java.lang.String sumarDias(int numDias) throws java.text.ParseExceptionMethod that adds a number of days to the system date.- Parameters:
numDias- Parameter that represents the number of days to add.- Returns:
- a string that represents the date returned on format
yyyy-mm-dd. - Throws:
java.text.ParseException- If the method fails.
-
getFechaMasNDias
public static java.lang.String getFechaMasNDias(java.lang.String fechaEnt, int diasAdd) throws java.text.ParseExceptionMethod that adds a number of days to certain date.- Parameters:
fechaEnt- Parameter that represents the date to add the days. It's a string withYYYYMMDDformat.diasAdd- Parameter that represents the number of days to add.- Returns:
- a string that represents the date returned on format
yyyyMMDD. - Throws:
java.text.ParseException- If the method fails.
-
convierteFecha
public static java.util.Date convierteFecha(java.lang.String fecha, java.lang.String patron) throws java.text.ParseExceptionMethod that obtains a date from a string using a determined pattern.- Parameters:
fecha- Parameter that represents the string to transform in date.patron- Parameter that represents the pattern used to generate the date.- Returns:
- a date from a string using a determined pattern.
- Throws:
java.text.ParseException- If the method fails.
-
-