Java GetTime Function

Post Reply
User avatar
vilian
Posts: 984
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Java GetTime Function

Post by vilian »

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
karinha
Posts: 7885
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: Java GetTime Function

Post by karinha »

Hola, Algo asi?

Code: Select all | Expand

// https://pt.stackoverflow.com/questions/494387/como-formatar-uma-data-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=convert ... e&ie=UTF-8

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Java GetTime Function

Post by nageswaragunupudi »

How could I convert a Date to a double value?
? HB_DateTime() - STOT("")
Regards

G. N. Rao.
Hyderabad, India
User avatar
vilian
Posts: 984
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Re: Java GetTime Function

Post by vilian »

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
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Java GetTime Function

Post by nageswaragunupudi »

Please explain your actual requirement.

Code: Select all | Expand

? HB_DateTime() // --> 2024-12-09 19:29:45
This is a DateTime value ( valtype "T" )
Regards

G. N. Rao.
Hyderabad, India
User avatar
vilian
Posts: 984
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Re: Java GetTime Function

Post by vilian »

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
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Java GetTime Function

Post by nageswaragunupudi »

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
vilian
Posts: 984
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Re: Java GetTime Function

Post by vilian »

Thank you,
It worked with FW_DateToUnix() ;)
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Post Reply