Example usage for java.time LocalDate parse

List of usage examples for java.time LocalDate parse

Introduction

In this page you can find the example usage for java.time LocalDate parse.

Prototype

public static LocalDate parse(CharSequence text) 

Source Link

Document

Obtains an instance of LocalDate from a text string such as 2007-12-03 .

Usage

From source file:Main.java

public static void main(String[] argv) {
    LocalDate d = LocalDate.parse("2013-01-12");
    System.out.println(d);
}

From source file:Foo.java

public static void main(String[] args) {
    System.out.println(LocalDate.parse("2014-05-03").minusWeeks(2));
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate fromIsoDate = LocalDate.parse("2014-01-20");

    System.out.println(fromIsoDate);
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate a = LocalDate.parse("2007-12-03");

    System.out.println(a);
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate ld1 = LocalDate.parse("2014-06-10");
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
    LocalDate ld2 = LocalDate.parse("06/10/2014", formatter);

    System.out.println("ld1: " + ld1);
    System.out.println("ld2: " + ld2);
}

From source file:Main.java

public static void main(String[] argv) {
    LocalDate date = LocalDate.parse("2013-01-12");
    TemporalQuery<Quarter> quarterOfYearQuery = new QuarterOfYearQuery();

    System.out.println(date.query(quarterOfYearQuery));
}

From source file:Main.java

public static void main(String[] argv) {
    LocalDate date = LocalDate.parse("2013-01-12");
    TemporalQuery<LocalDate> quarterOfYearQuery = new NextMartinLutherKingDayQuery();

    System.out.println(date.query(quarterOfYearQuery));
}

From source file:org.zaproxy.admin.PendingAddOnReleases.java

public static void main(String[] args) throws Exception {
    LocalDate now = LocalDate.now(ZoneOffset.UTC);
    boolean showChanges = true;

    ZapXmlConfiguration zapVersions = new ZapXmlConfiguration(Paths.get(ZAP_VERSIONS_FILE_NAME).toFile());
    AddOnCollection addOnCollection = new AddOnCollection(zapVersions, AddOnCollection.Platform.daily);

    zapVersions.setExpressionEngine(new XPathExpressionEngine());

    Set<AddOnData> addOns = getAllAddOns();
    int totalAddOns = addOns.size();

    Set<AddOnData> unreleasedAddOns = new TreeSet<>();
    Set<AddOnData> unchangedAddOns = new TreeSet<>();

    for (Iterator<AddOnData> it = addOns.iterator(); it.hasNext();) {
        AddOnData addOnData = it.next();
        AddOn addOn = addOnCollection.getAddOn(addOnData.getId());
        if (addOn == null) {
            unreleasedAddOns.add(addOnData);
            it.remove();/*from w w  w .ja v a 2  s . com*/
        } else if (addOn.getVersion().compareTo(addOnData.getVersion()) >= 0) {
            it.remove();
        } else if (addOnData.getChanges().isEmpty()) {
            unchangedAddOns.add(addOnData);
            it.remove();
        }
    }

    if (!unreleasedAddOns.isEmpty()) {
        System.out.println("=============================");
        System.out.println("Unreleased add-ons (" + unreleasedAddOns.size() + " of " + totalAddOns + ")");
        System.out.println("=============================");
        for (AddOnData addOn : unreleasedAddOns) {
            System.out.println(addOn.getStatus() + "\t" + addOn.getName() + " v" + addOn.getVersion());
        }
        System.out.println("=============================\n");
    }

    if (!addOns.isEmpty()) {
        System.out.println("=======================================");
        System.out.println("New versions pending release (" + addOns.size() + " of " + totalAddOns + ")");
        System.out.println("=======================================");
        Status currentStatus = null;
        for (AddOnData addOn : addOns) {
            if (currentStatus != addOn.getStatus()) {
                currentStatus = addOn.getStatus();
                System.out.println(currentStatus);
            }
            LocalDate releaseDate = LocalDate.parse(zapVersions.getString("/addon_" + addOn.getId() + "/date"));
            System.out.println("  * " + addOn.getName() + " v" + addOn.getVersion() + " ("
                    + Period.between(releaseDate, now) + ")");

            if (showChanges) {
                for (String change : addOn.getChanges()) {
                    System.out.println("       - " + change);
                }
            }
        }
        System.out.println("=======================================\n");
    }

    if (!unchangedAddOns.isEmpty()) {
        System.out.println("=============================");
        System.out.println("Unchanged add-ons (" + unchangedAddOns.size() + " of " + totalAddOns + ")");
        System.out.println("=============================");
        for (AddOnData addOn : unchangedAddOns) {
            System.out.println(addOn.getStatus() + "\t" + addOn.getName() + " v" + addOn.getVersion());
        }
        System.out.println("=============================\n");
    }
}

From source file:net.jmhertlein.mcanalytics.api.request.UniqueLoginsPerDayRequest.java

@Override
public Map<LocalDate, Integer> processResponse(JSONObject response) {
    JSONObject counts = response.getJSONObject("logins");
    LinkedHashMap<LocalDate, Integer> ret = new LinkedHashMap<>();
    for (String s : counts.keySet()) {
        ret.put(LocalDate.parse(s), counts.getInt(s));
    }/*from   w w w .  j  av  a  2  s.  c  o m*/

    return ret;
}

From source file:org.dozer.converters.LocalDateConverter.java

@Override
public Object convert(Class destClass, Object srcObj) {
    LocalDate convertedValue = null;
    try {/* ww  w  . jav a2 s  .  co m*/
        if (srcObj instanceof String) {
            convertedValue = LocalDate.parse((String) srcObj);
        } else {
            LocalDate srcObject = (LocalDate) srcObj;
            convertedValue = LocalDate.of(srcObject.getYear(), srcObject.getMonth(), srcObject.getDayOfMonth());
        }
    } catch (Exception e) {
        MappingUtils.throwMappingException("Cannot convert [" + srcObj + "] to LocalDate.", e);
    }
    return convertedValue;
}