Example usage for org.joda.time DateTime toString

List of usage examples for org.joda.time DateTime toString

Introduction

In this page you can find the example usage for org.joda.time DateTime toString.

Prototype

public String toString(String pattern) 

Source Link

Document

Output the instant using the specified format pattern.

Usage

From source file:io.terminus.snz.user.service.SupplierInfoChangedServiceImpl.java

@Override
public SupplierInfoChangedDto qualityChanged(Long userId, CompanyExtraQuality updatedQuality,
        CompanyExtraQuality oldQuality) {
    SupplierInfoChangedDto supplierInfoChangedDto = new SupplierInfoChangedDto();

    CompanyExtraQuality newQuality = getNewCompanyExtraQuality(userId, oldQuality).getSupplierInfo();

    Map<String, String> changedInfo = Maps.newHashMap();

    if (!Objects.equal(updatedQuality.getRohsId(), newQuality.getRohsId())) {
        changedInfo.put(ChangedInfoKeys.qualityRohsId(), updatedQuality.getRohsId());
        updatedQuality.setRohsId(null);/*from   w  w  w . j  a  v  a  2  s. c  o  m*/
    }
    if (!Objects.equal(updatedQuality.getRohsAttachUrl(), newQuality.getRohsAttachUrl())) {
        changedInfo.put(ChangedInfoKeys.qualityRohsAttachUrl(), updatedQuality.getRohsAttachUrl());
        updatedQuality.setRohsAttachUrl(null);
    }

    if (updatedQuality.getRohsValidDate() != null) {
        DateTime updatedRohsValidDate = new DateTime(updatedQuality.getRohsValidDate());
        if (newQuality.getRohsValidDate() == null) {
            changedInfo.put(ChangedInfoKeys.qualityRohsValidDate(), updatedRohsValidDate.toString(FORMATTER));
            updatedQuality.setRohsValidDate(null);
        } else {
            DateTime oldRohsValidDate = new DateTime(newQuality.getRohsValidDate());
            if (!updatedRohsValidDate.equals(oldRohsValidDate)) {
                changedInfo.put(ChangedInfoKeys.qualityRohsValidDate(),
                        updatedRohsValidDate.toString(FORMATTER));
                updatedQuality.setRohsValidDate(null);
            }
        }
    }

    if (!Objects.equal(updatedQuality.getIso9001Id(), newQuality.getIso9001Id())) {
        changedInfo.put(ChangedInfoKeys.qualityISO9001Id(), updatedQuality.getIso9001Id());
        updatedQuality.setIso9001Id(null);
    }
    if (!Objects.equal(updatedQuality.getIso9001AttachUrl(), newQuality.getIso9001AttachUrl())) {
        changedInfo.put(ChangedInfoKeys.qualityISO9001AttachUrl(), updatedQuality.getIso9001AttachUrl());
        updatedQuality.setIso9001AttachUrl(null);
    }

    if (updatedQuality.getIso9001ValidDate() != null) {
        DateTime updatedIso9001ValidDate = new DateTime(updatedQuality.getIso9001ValidDate());
        if (newQuality.getIso9001ValidDate() == null) {
            changedInfo.put(ChangedInfoKeys.qualityISO9001ValidDate(),
                    updatedIso9001ValidDate.toString(FORMATTER));
            updatedQuality.setIso9001ValidDate(null);
        } else {
            DateTime oldIso9001ValidDate = new DateTime(newQuality.getIso9001ValidDate());
            if (!updatedIso9001ValidDate.equals(oldIso9001ValidDate)) {
                changedInfo.put(ChangedInfoKeys.qualityISO9001ValidDate(),
                        updatedIso9001ValidDate.toString(FORMATTER));
                updatedQuality.setIso9001ValidDate(null);
            }
        }
    }

    if (!Objects.equal(updatedQuality.getIso14001Id(), newQuality.getIso14001Id())) {
        changedInfo.put(ChangedInfoKeys.qualityISO14001Id(), updatedQuality.getIso14001Id());
        updatedQuality.setIso14001Id(null);
    }
    if (!Objects.equal(updatedQuality.getIso14001AttachUrl(), newQuality.getIso14001AttachUrl())) {
        changedInfo.put(ChangedInfoKeys.qualityISO14001AttachUrl(), updatedQuality.getIso14001AttachUrl());
        updatedQuality.setIso14001AttachUrl(null);
    }

    if (updatedQuality.getIso14001ValidDate() != null) {
        DateTime updatedIso14001ValidDate = new DateTime(updatedQuality.getIso14001ValidDate());
        if (newQuality.getIso14001ValidDate() == null) {
            changedInfo.put(ChangedInfoKeys.qualityISO14001ValidDate(),
                    updatedIso14001ValidDate.toString(FORMATTER));
            updatedQuality.setIso14001ValidDate(null);
        } else {
            DateTime oldIso14001ValidDate = new DateTime(newQuality.getIso14001ValidDate());
            if (!updatedIso14001ValidDate.equals(oldIso14001ValidDate)) {
                changedInfo.put(ChangedInfoKeys.qualityISO14001ValidDate(),
                        updatedIso14001ValidDate.toString(FORMATTER));
                updatedQuality.setIso14001ValidDate(null);
            }
        }
    }

    if (!Objects.equal(updatedQuality.getTs16949Id(), newQuality.getTs16949Id())) {
        changedInfo.put(ChangedInfoKeys.qualityTS16949Id(), updatedQuality.getTs16949Id());
        updatedQuality.setTs16949Id(null);
    }
    if (!Objects.equal(updatedQuality.getTs16949AttachUrl(), newQuality.getTs16949AttachUrl())) {
        changedInfo.put(ChangedInfoKeys.qualityTS16949AttachUrl(), updatedQuality.getTs16949AttachUrl());
        updatedQuality.setTs16949AttachUrl(null);
    }

    if (updatedQuality.getTs16949ValidDate() != null) {
        DateTime updatedTs16949ValidDate = new DateTime(updatedQuality.getTs16949ValidDate());
        if (newQuality.getTs16949ValidDate() == null) {
            changedInfo.put(ChangedInfoKeys.qualityTS16949ValidDate(),
                    updatedTs16949ValidDate.toString(FORMATTER));
            updatedQuality.setTs16949ValidDate(null);
        } else {
            DateTime oldTs16949ValidDate = new DateTime(newQuality.getTs16949ValidDate());
            if (!updatedTs16949ValidDate.equals(oldTs16949ValidDate)) {
                changedInfo.put(ChangedInfoKeys.qualityTS16949ValidDate(),
                        updatedTs16949ValidDate.toString(FORMATTER));
                updatedQuality.setTs16949ValidDate(null);
            }
        }
    }

    if (!changedInfo.isEmpty()) {
        supplierInfoChangedDto.setChanged(true);
        supplierInfoChangedDto.setChangedInfo(changedInfo);
    }
    return supplierInfoChangedDto;
}

From source file:io.terminus.snz.user.service.SupplierInfoChangedServiceImpl.java

/**
 * ?// ww  w  .j  av a2  s.  c  o m
 */
private void checkBusinessLicense(Map<String, String> changedInfo, PaperworkDto updatedPaperwork,
        PaperworkDto oldPaperwork) {

    if (!Objects.equal(updatedPaperwork.getBusinessLicense(), oldPaperwork.getBusinessLicense())) {
        changedInfo.put(ChangedInfoKeys.companyBusinessLicense(), updatedPaperwork.getBusinessLicense());
    }
    if (!Objects.equal(updatedPaperwork.getBusinessLicenseId(), oldPaperwork.getBusinessLicenseId())) {
        changedInfo.put(ChangedInfoKeys.companyBusinessLicenseId(), updatedPaperwork.getBusinessLicenseId());
    }

    DateTime updatedBlDate = new DateTime(updatedPaperwork.getBlDate());
    if (oldPaperwork.getBlDate() == null) {
        changedInfo.put(ChangedInfoKeys.companyBusinessLicenseDate(), updatedBlDate.toString(FORMATTER));
    } else {
        DateTime oldBlDate = new DateTime(oldPaperwork.getBlDate());
        if (!updatedBlDate.isEqual(oldBlDate)) {
            changedInfo.put(ChangedInfoKeys.companyBusinessLicenseDate(), updatedBlDate.toString(FORMATTER));
        }
    }
}

From source file:io.terminus.snz.user.service.SupplierInfoChangedServiceImpl.java

/**
 * // w w w .  j a v a 2s .  co  m
 */
private void checkOrgCert(Map<String, String> changedInfo, PaperworkDto updatedPaperwork,
        PaperworkDto oldPaperwork) {

    if (!Objects.equal(updatedPaperwork.getOrgCert(), oldPaperwork.getOrgCert())) {
        changedInfo.put(ChangedInfoKeys.companyOrgCert(), updatedPaperwork.getOrgCert());
    }
    if (!Objects.equal(updatedPaperwork.getOrgCertId(), oldPaperwork.getOrgCertId())) {
        changedInfo.put(ChangedInfoKeys.companyOrgCertId(), updatedPaperwork.getOrgCertId());
    }

    DateTime updatedOcDate = new DateTime(updatedPaperwork.getOcDate());
    if (oldPaperwork.getOcDate() == null) {
        changedInfo.put(ChangedInfoKeys.companyOrgCertDate(), updatedOcDate.toString(FORMATTER));
    } else {
        DateTime oldOcDate = new DateTime(oldPaperwork.getOcDate());
        if (!updatedOcDate.isEqual(oldOcDate)) {
            changedInfo.put(ChangedInfoKeys.companyOrgCertDate(), updatedOcDate.toString(FORMATTER));
        }
    }
}

From source file:io.typebrook.fiveminsmore.Cluster.CustomMarker.java

License:Apache License

public void setDateTime(DateTime time) {
    mTime = time;/* w  w  w  . j a  va2  s .c  om*/
    DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MMMM-dd a HH:mm")
            .withZone(DateTimeZone.forOffsetHours(8));
    mSnippet = ": " + time.toString(fmt) + "\n" + mSnippet;
}

From source file:io.v.android.apps.account_manager.CertificateDisplayActivity.java

License:Open Source License

/**
 * Returns a human-readable description of a caveat.
 *
 * @param caveat        the caveat to be examined
 * @return              a human-readable description of the caveat
 *//* w w w.  j av  a 2s.  c o  m*/
public static String caveatText(Caveat caveat) {
    Id caveatId = caveat.getId();
    if (caveatId.equals(Constants.CONST_CAVEAT.getId())) {
        return "Const Caveat";
    } else if (caveatId.equals(Constants.EXPIRY_CAVEAT.getId())) {
        String ret = "Expiry Caveat: ";
        try {
            DateTime expiry = expiryCaveatPayload(caveat);
            ret += expiry.toString(DateTimeFormat.mediumDateTime());
        } catch (VException e) {
            android.util.Log.e(TAG, "Error parsing expiry caveat payload: " + e);
            ret += "Could not get expiry time";
        }
        return ret;
    } else if (caveatId.equals(Constants.METHOD_CAVEAT.getId())) {
        String ret = "Method Caveat: ";
        try {
            List<String> methods = methodCaveatPayload(caveat);
            for (String name : methods) {
                ret += name + "\n";
            }
        } catch (VException e) {
            android.util.Log.e(TAG, "Error parsing method caveat payload: " + e);
            ret += "Could not get method names";
        }
        return ret;
    } else if (caveatId.equals(Constants.PEER_BLESSINGS_CAVEAT.getId())) {
        return "Peer Blessings Caveat";
    } else if (caveatId.equals(Constants.PUBLIC_KEY_THIRD_PARTY_CAVEAT.getId())) {
        return "Public Key Third Party Caveat";
    } else {
        return "Unknown Caveat";
    }
}

From source file:isjexecact.br.com.inso.utils.Funcoes.java

/**
 * Retorna a Hora Atual.//from  ww  w.  jav a2 s  . c o m
 * @return Hora no formato hh:mm:ss
 */
public static String getHoraAtual() {
    // Glauber 11/09/2014 - Estou trocando pelo componente joda-time para me livrar da dor de cabea de utiilzar as classes nativa do Java.
    DateTime dateTime = new DateTime();
    return dateTime.toString("HH:mm:ss");

    //        Calendar greg = Calendar.getInstance(); //GregorianCalendar();  
    //        SimpleDateFormat formato = new SimpleDateFormat("HH:mm:hh");  
    //        return(formato.format(greg.getTime()));           
}

From source file:isjexecact.br.com.inso.utils.Funcoes.java

/**
 * Retorna a Hora Atual no formato timestamp.
 * @return Hora no formato hhmmss/*from w  w  w  .  j  a v  a 2 s  .co  m*/
 */
public static String getHoraAtualTstp() {
    // Glauber 11/09/2014 - Estou trocando pelo componente joda-time para me livrar da dor de cabea de utiilzar as classes nativa do Java.
    DateTime dateTime = new DateTime();
    return dateTime.toString("HHmmss");

    //        Calendar greg = Calendar.getInstance(); //GregorianCalendar();  
    //        SimpleDateFormat formato = new SimpleDateFormat("HHmmhh");  
    //        return(formato.format(greg.getTime()));           
}

From source file:isjexecact.br.com.inso.utils.Funcoes.java

/**
 * Retorna o timestamp no formato YYYYMMDDhhmmss.
 * @return String no formato YYYYMMDDhhmmss
 *//* w ww . java 2 s.  com*/
public static String getTimeStamp() {
    // Glauber 11/09/2014 - Estou trocando pelo componente joda-time para me livrar da dor de cabea de utiilzar as classes nativa do Java.
    DateTime dateTime = new DateTime();
    return dateTime.toString("YYYYMMddHHmmss");

    //GregorianCalendar greg = new GregorianCalendar();  
    //        Calendar greg = Calendar.getInstance();  
    //        SimpleDateFormat formato = new SimpleDateFormat("yyyyMMddHHmmhh");  
    //        return(formato.format(greg.getTime()));           
}

From source file:isjexecact.br.com.inso.utils.Funcoes.java

/**
 * Retorna a data corrente no formato yyyymmdd.
 * @return String no formato yyyymmdd.//w w w .jav a 2 s  .  c  om
 */
public static String getDtosCurrentDate() {
    // Glauber 11/09/2014 - Estou trocando pelo componente joda-time para me livrar da dor de cabea de utiilzar as classes nativa do Java.
    DateTime dateTime = new DateTime();
    return dateTime.toString("YYYYMMdd");

    //        GregorianCalendar greg = new GregorianCalendar();  
    //        SimpleDateFormat formato = new SimpleDateFormat("yyyyMMdd");  
    //        return(formato.format(greg.getTime()));           
}

From source file:isjexecact.br.com.inso.utils.Funcoes.java

/**
 * Retorna a data e hora corrente no formato brasileiro.
 * @return//from   w  w w .  ja va 2 s  .  co  m
 */
public static String getDataHoraBrasil() {
    DateTime dateTime = new DateTime();
    return dateTime.toString("dd/MM/YYYY HH:mm:ss");

    // Glauber 11/09/2014 - Estou trocando pelo componente joda-time para me livrar da dor de cabea de utiilzar as classes nativa do Java.

    // Imprimindo a data no formato YYYY-MM-dd HH:mm:ss 
    //System.out.println("dateTime.toString() = " + dateTime.toString("YYYY-MM-dd HH:mm:ss")); 

    /*
            
                    
            TimeZone timeZone = TimeZone.getTimeZone("GMT");
            GregorianCalendar greg = new GregorianCalendar();  
            greg.setTimeZone(timeZone);
            SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy - HH:mm:hh");  
            return(formato.format(greg.getTime()));                   
    */
}