“Chaîne java à horodatage” Réponses codées

Comment convertir l'horodatage en temps à Java

//Timestamp to HH:mm:ss format
Long Timestamp = 1633304782;
Date timeD = new Date(Timestamp * 1000);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");

String Time = sdf.format(timeD);

//RESULT this code convert 1633304782 to 05:46:33
Healthy Heron

horodatage à ce jour java

String timestampToDate(long timestamp, String pattern)
    {
        Date timeD = new Date(timestamp);
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        return sdf.format(timeD);
    }

//You can use this for both date or time.
// long timestamp = System.currentTimeMillis();
// eg: for date use it like this:
//timestampToDate(timestamp, "dd MMM, yyyy");
// eg: for time use it like this:
//timestampToDate(timestamp, "hh:mm a");
// eg: for both:
//timestampToDate(timestamp, "dd MMM, yyyy - hh:mm a");
MicroProgramer

Chaîne java à horodatage

import java.sql.Timestamp;

public class StringToTimeStamp {
    public static void main(String[] args) {

        String dateTime = "2020-12-12 01:24:23";

        Timestamp timestamp = Timestamp.valueOf(dateTime);
        System.out.println(timestamp);
    }
}
Michelle Hofer

Réponses similaires à “Chaîne java à horodatage”

Questions similaires à “Chaîne java à horodatage”

Plus de réponses similaires à “Chaîne java à horodatage” dans Sql

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code