Java GetTime Function

Java GetTime Function

Postby vilian » Fri Dec 06, 2024 6:40 pm

Hi Guys,
Do you know if is there in Harbour/Fivewin any function like GetTime() from Java ?
Or
How could I convert a Date to a double value?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 982
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: Java GetTime Function

Postby karinha » Fri Dec 06, 2024 7:56 pm

Hola, Algo asi?

Code: Select all  Expand view  RUN

// https://pt.stackoverflow.com/questions/ ... no-harbour

#Include "FiveWin.ch"

FUNCTION Main()

   SET CENTURY ON
   SET DATE BRITISH
   SET TIME FORMAT TO "HH:MM:SS"
   SET EPOCH TO YEAR( DATE() ) - 30
   SET SOFTSEEK OFF
   SET WRAP ON
   SETCANCEL( .F. )
   SET CONFIRM OFF
   SET DELETED ON
   SET _3DLOOK ON
   SET UNIQUE OFF
   SET ESCAPE OFF
   SET EXACT ON       // CONTROLA O :=, = e ==
   SET EXCLUSIVE OFF
   SET MULTIPLE OFF
   SET OPTIMIZE ON

   ? hb_Dtoc( Date(), "YYYY-MM-DD" )

   ? hb_Dtoc( Date(), "DD-MM-YYYY" )

   ? hb_Dtoc( Date(), "MMDDYY"     )

   ? hb_Dtoc( Date(), "DDMMYY"     )

RETURN NIL

FUNCTION hb_Dtoc( dData, dFormat )

   IF dFormat == NIL

      RETURN Dtoc( dData )

   ENDIF

   dFormat := Upper( dFormat )
   dFormat := StrTran( dFormat, "DD",   StrZero( Day( dData ), 2 ) )
   dFormat := StrTran( dFormat, "MM",   StrZero( Month( dData ), 2 ) )
   dFormat := StrTran( dFormat, "YYYY", StrZero( Year( dData ), 4 ) )
   dFormat := StrTran( dFormat, "YY",   StrZero( Mod( Year( dData ), 100 ), 2 ) )

RETURN( dFormat )

// FIN / END
 


https://www.google.com/search?q=converter+uma+data+em+um+valor+duplo+harbour&oq=converter+uma+data+em+um+valor+duplo+harbour&aqs=chrome..69i57j33i160l2.5227j0j15&sourceid=chrome&ie=UTF-8

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Java GetTime Function

Postby nageswaragunupudi » Sat Dec 07, 2024 8:14 pm

How could I convert a Date to a double value?


? HB_DateTime() - STOT("")
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Java GetTime Function

Postby vilian » Mon Dec 09, 2024 10:42 am

Mr Rao,

When i tried HB_DateTime() - STOT("") the function i called is receiving this date 14/01/8637
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 982
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: Java GetTime Function

Postby nageswaragunupudi » Mon Dec 09, 2024 2:01 pm

Please explain your actual requirement.

Code: Select all  Expand view  RUN
? HB_DateTime() // --> 2024-12-09 19:29:45

This is a DateTime value ( valtype "T" )
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Java GetTime Function

Postby vilian » Mon Dec 09, 2024 2:09 pm

I need to call this function:

PIXCD_ConsultarPixRecebidos(ADataInicio, ADataFim, ATxId, ACpfCnpj, PagAtual, ItensPorPagina, sResposta, esTamanho)

Where aDataInic and aDataFim are from DATE type. That i've declared by this way:

DLL32 FUNCTION PIXCD_ConsultarPixRecebidos(ADataInicio AS _DOUBLE,ADataFim AS _DOUBLE,ATxId AS STRING,;
ACpfCnpj AS STRING, PagAtual AS _INT, ItensPorPagina AS _INT,;
@sResposta AS STRING,@nTamanho AS _INT) AS LONG PASCAL FROM "PIXCD_ConsultarPixRecebidos" LIB oACPx
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 982
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: Java GetTime Function

Postby nageswaragunupudi » Mon Dec 09, 2024 2:35 pm

Do you propose to use
days.fraction of day
as double?
Hope you made sure in which format that software expects the date-time values.

Another most important thing is what is the Epoch date. This differs from software to software.
Microsoft' Ole sources count date/time from epoch Jan 1, 1900 00 hours
Unix / java/ etc start with Jan 1 1970 00 hours

FW_DateToUnix( tHarbourDateTime ) --> nMilliSeconds ( Unixtime )

The value we provide depends on what the other library actually expects
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Java GetTime Function

Postby vilian » Mon Dec 09, 2024 5:50 pm

Thank you,
It worked with FW_DateToUnix() ;)
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 982
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 15 guests