Answers for "convert string to date"

26

string to date python

import datetime

date_time_str = '2018-06-29 08:15:27.243860'
date_time_obj = datetime.datetime.strptime(date_time_str, '%Y-%m-%d %H:%M:%S.%f')

print('Date:', date_time_obj.date())
print('Time:', date_time_obj.time())
print('Date-time:', date_time_obj)
Posted by: Guest on June-01-2020
18

string to date

string iDate = "05/05/2005";
DateTime oDate = Convert.ToDateTime(iDate);
MessageBox.Show(oDate.Day + " " + oDate.Month + "  " + oDate.Year );
Posted by: Guest on March-08-2020
14

string to date conversion java

import java.text.SimpleDateFormat;  
import java.util.Date;  
public class StringToDateExample1 {  
public static void main(String[] args)throws Exception {  
    String sDate1="31/12/1998";  
    Date date1=new SimpleDateFormat("dd/MM/yyyy").parse(sDate1);  
    System.out.println(sDate1+"\t"+date1);  
}  
}
Posted by: Guest on July-30-2020
5

How to convert string to date in Java 8

// How to convert string to date in Java 8
import java.time.LocalDate;
import java.time.LocalDateTime;
public class Java8StringToDate
{
   public static void main(String[] args)
   {
      DateTimeFormatter dtf1 = DateTimeFormatter.ofPattern("d/MM/yyyy");
      String strDate1 = "14/05/2005";
      LocalDate ld1 = LocalDate.parse(strDate1, dtf1); 
      System.out.println(ld1);
      DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("MMM d yyyy");
      String strDate2 = "May 14 2005";
      LocalDate ld2 = LocalDate.parse(strDate2, dtf2); 
      System.out.println(ld2);
   }
}
Posted by: Guest on February-22-2021
1

convert string date to datetime and format

var dateString = "2020-09-25T10:13:21.246321+01:00";
String formattedDateString = DateFormat('do LLLL yyyy').format(DateTime.parse(dateString)); 
// formattedDateString - OUTPUT: "25 September 2020"
Posted by: Guest on September-25-2020
0

from string to date

String dtStart = "2010-10-15T09:27:37Z";  
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");  
try {  
    Date date = format.parse(dtStart);  
    System.out.println(date);  
} catch (ParseException e) {
    e.printStackTrace();  
}
Posted by: Guest on April-27-2021

Code answers related to "convert string to date"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language