Skip to main content
Emmanuel Corona preguntó en #Apex
Hello i have this trigger and works ok, the problem is that date field (not datetime) returns me the date in yyyy/mm/dd 00:00:00 format and i would like to get the date in DD/MM/YYYY format. This is the Date field Fecha_de_Vencimiento_de_Contrato__c

I will really appreciate your help

 List<Id> conIds = new List<Id>();

   

    if(trigger.isDelete){

        for(Proveedores__c c : Trigger.old){

            conIds.add(c.Cuenta__c);

        }

    }else{

        for(Proveedores__c c : Trigger.new){

        conIds.add(c.Cuenta__c);

        }

    }

    

    List<Account> ProveedoresAccount = [Select id, name, Proveedores_Resumen__c, (Select tipo_de_proveedor__c, Proveedores__c, 

                                        Fecha_de_Vencimiento_de_Contrato__c   from Proveedores__r) from Account where id in : conIds];   

    

    for(Account a: ProveedoresAccount){

        String Proveedores='';

        for(Proveedores__c pro : a.Proveedores__r){

            Proveedores=Proveedores+': '+pro.tipo_de_proveedor__c+': '+pro.Proveedores__c+': '+pro.Fecha_de_Vencimiento_de_Contrato__c +'/' ;       

        }

        a.Proveedores_Resumen__c= Proveedores;

        update(a);

    }
8 respuestas
  1. 18 may 2017, 20:43

    Try this.

    for(Account a: ProveedoresAccount){

    String Proveedores='';

    for(Proveedores__c pro : a.Proveedores__r){

    String datevalue = 'No date Specified' ;

    if(pro.Fecha_de_Vencimiento_de_Contrato__c != null) {

    datevalue = String.valueOf(pro.Fecha_de_Vencimiento_de_Contrato__c.format());

    }

    Proveedores =

    Proveedores + ': ' + pro.tipo_de_proveedor__c +

    ': '+pro.Proveedores__c + ': ' + datevalue +'/' ;

    }

    a.Proveedores_Resumen__c = Proveedores;

    update(a);

    }

     
0/9000