Wednesday 24 January 2018

How to format LocalDateTime | LocalDateTime Class | Java 8 Date and Time


Click here to watch on Youtube : 
https://www.youtube.com/watch?v=vw2VXSbKAMk&list=UUhwKlOVR041tngjerWxVccw

LocalDateTimeDemo.java

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

public class LocalDateTimeDemo
{

    public static void main(String[] args)
    {
        LocalDateTime localDateTime = LocalDateTime
                .parse("2017-02-03T12:30:30");
        System.out.println(localDateTime);
       
       
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_DATE;
        /*
         * Parameters:
         *
         * temporal - the temporal object to format, not null
         *
         * Returns:
         *
         * the formatted string, not null
         */


        String formatedStrDate = dateTimeFormatter.format(localDateTime);
        System.out.println(formatedStrDate);
    }

}

Output

2017-02-03T12:30:30
2017-02-03

Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/LocalDateTimeDemo_format_how.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/LocalDateTimeDemo_format_how

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/2732bd5046563d647669928b143687e5dbf4d99f/BasicJava/LocalDateTimeDemo_format_how/?at=master

See also:
  • All JavaEE Videos Playlist
  • All JavaEE Videos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • No comments:

    Post a Comment