Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

create new LocalDate java

LocalDate date = LocalDate.of(2021, 09, 13);
Comment

how to create localdate object in java

// to get date of today Java 8 class
LocalDate date = LocalDate.now();
Comment

localDate java

package br.com.dicasdejava.fundamentos;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class FormatarLocalDate {

    public static void main(String[] args) {

        //Obtém LocalDate de hoje
        LocalDate hoje = LocalDate.now();

        System.out.println("LocalDate antes de formatar: " + hoje);

        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");

        String hojeFormatado = hoje.format(formatter);

        System.out.println("LocalDate depois de formatar: " + hojeFormatado);

        //Obtém LocalDateTime de agora
        LocalDateTime agora = LocalDateTime.now();

        System.out.println("LocalDateTime antes de formatar: " + agora);

        formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss");

        String agoraFormatado = agora.format(formatter);

        System.out.println("LocalDateTime depois de formatar: " + agoraFormatado);

    }

}
Comment

PREVIOUS NEXT
Code Example
Java :: how to center a window in java 
Java :: encapsulation in oop 
Java :: java convert edittext to double 
Java :: java get number of months between two dates 
Java :: arraylist replace value java 
Java :: java formatted output 
Java :: Converting String Array to an Integer Array 
Java :: spring filter exception handling 
Java :: find elements in selenium 
Java :: how to set boolean to false if null java 
Java :: transpose of a matrix java 
Java :: polymorphism in oop 
Java :: load contents of file into string java 
Java :: java append a string to file 
Java :: how to change tablayout current view position in android 
Java :: center textview programmatically android 
Java :: how to get 2 decimal places in java 
Java :: Java program to print decimal to octal conversion 
Java :: mono command to compile C# library code 
Java :: java iterate map and remove 
Java :: how to make arraylist character 
Java :: switch case enum java 
Java :: Java do...while loop 
Java :: word count in a string using HashMap Collection 
Java :: multiple condition inside for loop java 
Java :: getsource java 
Java :: hashmap get value by key java 
Java :: convertir string a char java 
Java :: line break in android xml dynamically 
Java :: java cannot find file path 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =