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 hashmap key exists 
Java :: convert int[] to list java 
Java :: java parse unix timestamp 
Java :: math.sin java 
Java :: java how to check string is number 
Java :: get time android 
Java :: java tomorrow date 
Java :: java loop array backwards 
Java :: Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.android.sdklib.repositoryv2.AndroidSdkHandler 
Java :: action bar spigot 
Java :: java send request 
Java :: string to float java 
Java :: string to byte array java 
Java :: java.lang.IllegalArgumentException: Invalid character found in method name 
Java :: java split string by length 
Java :: how to get the smallest number in an array java 
Java :: how to initialize a set in java 
Java :: modal css react 
Java :: core java tutorial 
Java :: how to print an array in java 
Java :: running sum of 1d array java 
Java :: Delete end element in string java 
Java :: java leap year 
Java :: JAVA Display Sum of n Natural Numbers 
Java :: how to change theme of app in android studio programmatically 
Java :: java for each loop 
Java :: arraylist to int array conversion in java 
Java :: redondear a 2 decimales java 
Java :: runtime intalize array in java 
Java :: jdbc interface 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =