Wednesday, November 28, 2018

JAVA - How to work with LocalDateTime

/* now() */
    
LocalDateTime dateNow = LocalDateTime.now();
System.out.println( dateNow );        
System.out.println( dateNow.format( DateTimeFormatter.ofPattern( "dd.MM.yyyy H:m:s" ) ) );
    
/* defined datetime 1. Jan 2018 17:00 h */
    
LocalDateTime date = LocalDateTime.of( 2018, 1, 1, 17, 0, 0 );
System.out.println( date.format( DateTimeFormatter.ofPattern( "dd.MM.yyyy H:m:s" ) ) );
    
/* ..add 25 minutes to previous */
    
LocalDateTime dateend = date.plusMinutes( 25 );
System.out.println( dateend.format( DateTimeFormatter.ofPattern( "dd.MM.yyyy H:m:s" ) ) );
    
/* ..and check difference in minutes */
    
System.out.println( date.until( dateend, MINUTES ) );
Output:
2018-11-28T09:50:58.724
28.11.2018 9:50:58
01.01.2018 17:0:0
01.01.2018 17:25:0
25

DELPHI - How work with memory table (TFDMemTable)

Variant 1) Copy data from TDataSet to TFDMemTable:
var
  pMemTable : TFDMemTable;
  pQuery : TFDQuery;
begin
  ...
  pMemTable := TFDMemTable.Create( self );
  pMemTable.CloneCursor( pQuery );
  ...

Variant 2) Define own structure of TFDMemTable:
var
  pMemTable : TFDMemTable;
  pQuery : TFDQuery;
begin
  ...
  pMemTable := TFDMemTable.Create( self );
  pMemTable.FieldDefs.Add( 'key', ftString, 25 );
  pMemTable.FieldDefs.Add( 'value', ftString, 25 );
  pMemTable.CreateDataSet();
  ...
  pMemTable.AppendRecord( [ 'firstkey', 'firstvalue' ] );
  ...

Friday, November 23, 2018

DELPHI - How to solve error "...E2009 Incompatible types: 'method pointer and regular procedure'"

..try to surround called procedure as class procedure in class.
type
  TEachRowProcedures = class
  public
    class procedure ExportAsHTML_Proc( ARowIndex: Integer; ARowInfo: TcxRowInfo );
  end;
Call as:
...
_pView.DataController.ForEachRow( true, TEachRowProcedures.ExportAsHTML_Proc );

Wednesday, November 14, 2018

SSRS - How to make different color for bar of charts

When you need different color from bar of chart - here different for actual week:

1) Click with right mouse button on chart row value.

2) And for bar color use this expression:
=IIf(Fields!ID_week.Value=DATEPART(DateInterval.WeekOfYear, Today()), "LimeGreen","Tomato")