Answers for "zoneDateTime to date java"

1

get date by timezone java

Date date = new Date();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

// Use Madrid's time zone to format the date in
df.setTimeZone(TimeZone.getTimeZone("Europe/Madrid"));

System.out.println("Date and time in Madrid: " + df.format(date));
Posted by: Guest on July-23-2020
1

convert date to datetime java

Fixed it using this:

public DateTime dateAndTimeToDateTime(java.sql.Date date, java.sql.Time time) {
    String myDate = date + " " + time;
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    java.util.Date utilDate = new java.util.Date();
    try {
        utilDate = sdf.parse(myDate);
    } catch (ParseException pe){
        pe.printStackTrace();
    }
    DateTime dateTime = new DateTime(utilDate);

    return dateTime;
}
Posted by: Guest on March-22-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language