Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

android java format date time

import java.time.*;
import java.time.format.*;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime datetime = LocalDateTime.now();
String output = formatter.format(datetime);
Comment

date format in android

String date="Mar 10, 2016 6:30:00 PM";
SimpleDateFormat spf=new SimpleDateFormat("MMM dd, yyyy hh:mm:ss aaa");
Date newDate=spf.parse(date);
spf= new SimpleDateFormat("dd MMM yyyy");
date = spf.format(newDate);
System.out.println(date);
Comment

android java format date time

import java.time.*;
import java.time.format.*;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date = LocalDate.now();
String output = formatter.format(date);
Comment

date format android


    private fun setDateFormat() {
        val c = Calendar.getInstance()

        val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(c.time)

        val sdfDate = SimpleDateFormat("yyyy-MMM-dd").format(c.time)
        //(yyyy-MMM-dd -> 2022-Jan-14), (yyyy-MM-dd -> 2022-01-14), (yyyy-MMMM-dd -> 2022-January-14)

        val sdfTime24 = SimpleDateFormat("HH:mm:ss aa").format(c.time)

        val sdfTimeAm = SimpleDateFormat("hh:mm aa").format(c.time)

        Log.d("Date",
            "
 sdf : $sdf" +
                    "
 sdfDate : $sdfDate" +
                    "
 sdfTime24 : $sdfTime24" +
                    "
 sdfTimeAm : $sdfTimeAm")

        /*
        * Outut
        * sdf : 2022-01-14 21:09:54
        * sdfDate : 2022-Jan-14
        * sdfTime24 : 21:09:54 pm
        * sdfTimeAm : 09:09 pm
        */

    }
Comment

android date format


    private fun setDateFormat() {
        val c = Calendar.getInstance()

        val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(c.time)

        val sdfDate = SimpleDateFormat("yyyy-MMM-dd").format(c.time)
        //(yyyy-MMM-dd -> 2022-Jan-14), (yyyy-MM-dd -> 2022-01-14), (yyyy-MMMM-dd -> 2022-January-14)

        val sdfTime24 = SimpleDateFormat("HH:mm:ss aa").format(c.time)

        val sdfTimeAm = SimpleDateFormat("hh:mm aa").format(c.time)

        Log.d("Date",
            "
 sdf : $sdf" +
                    "
 sdfDate : $sdfDate" +
                    "
 sdfTime24 : $sdfTime24" +
                    "
 sdfTimeAm : $sdfTimeAm")

        /*
        * Outut
        * sdf : 2022-01-14 21:09:54
        * sdfDate : 2022-Jan-14
        * sdfTime24 : 21:09:54 pm
        * sdfTimeAm : 09:09 pm
        */

    }
Comment

android java format date time

import java.time.*;
import java.time.format.*;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
LocalTime time = LocalTime.now();
String output = formatter.format(time);
Comment

PREVIOUS NEXT
Code Example
Java :: java download file 
Java :: protocollib onenable 
Java :: java jshell run string as code 
Java :: fizzbuzz java 
Java :: spring config.xml file 
Java :: java 2d game tutorial 
Java :: java console write 
Java :: right click java 
Java :: lombok get error in extended classes¨ 
Java :: how to show full search bar in android studio 
Java :: Captain Disillusion age 
Java :: androidx.fragment.app.Fragment$InstantiationException 
Java :: bukkit java connect player to another server in bungeecord 
Java :: programatically close a jframe 
Java :: leetcode 416 
Java :: android how to determine if the edit text focus changes 
Java :: Date from String java11 
Java :: print line number java 
Java :: check if object in array java 
Java :: character.isalphanumeric java 
Java :: java arraylist get second largest value 
Java :: android studio start activity 
Java :: load a file from classpath spring boot 
Java :: list in java 
Java :: converter int array para string java 
Java :: Java Using forName() method 
Java :: duplicate local variable in java 
Java :: how to read a text file in java 
Java :: get logged-in user in Spring Security 
Java :: map string list string in java 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =