Convert DateTime to String

convert datetime to string sql
convert datetime to string java
convert datetime to string php
convert datetime to string matlab
convert datetime to string pandas
convert datetime to string javascript
convert date to string
convert datetime back to string

I would appreciate if you could help me to achieve a conversion from DateTime format (08/30/2018) to this type of String "August 30, 2018". I am working with refreshes and I would like to show on a TextView something like that. Thank you

Use this code for conversion:

SimpleDateFormat inputFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.getDefault());
SimpleDateFormat outputFormat = new SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault());
Date date;
String result = "";
try {
    date = inputFormat.parse("set your input date here");
    result = outputFormat.format(date); // here will be output date
} catch (e: ParseException) {
    Log.e("Error", "Parse exception", e);

Python's datetime class provides a member function strftime() to create string representation of data in the object i.e.. Converts the value of the current DateTime object to its equivalent string representation using the specified format and culture-specific format information. ToString(String) Converts the value of the current DateTime object to its equivalent string representation using the specified format and the formatting conventions of the current culture.

try this

 String date ="2017-05-05 13:58:50 ";
            SimpleDateFormat input = new SimpleDateFormat("MM/dd/yyyy");
            SimpleDateFormat output = new SimpleDateFormat("MMMM dd,yyyy");
            try {
                 Date oneWayTripDate = input.parse(date);  // parse input
            } catch (ParseException e) {

You can use strftime to help you format your date. E.g., import datetime t = datetime.datetime(2012, 2, 23, 0, 0) t.strftime('%m/%d/%Y'). will yield: To parse a DateTime, use one of the following methods: DateTime.Parse; DateTime.ParseExact; Alternatively, you may use try-parse pattern: DateTime.TryParse; DateTime.TryParseExact; Read more about Custom Date and Time Format Strings. Converting DateTime to a string: To return a DateTime as a string in "yyyyMMdd" format, you may use ToString method.

Use this sample:

SimpleDateFormat sdf = new SimpleDateFormat("HH:mm dd/MM/yyyy"); Date now = new Date(); String time = sdf.format(now);

Converts the value of the current DateTime object to its equivalent string representation using the formatting conventions of the current culture. ToString(​String,  Convert the date part only from datetime object to string in format DD MMM YYYY Python dateStr = dateTimeObj.strftime("%d %b %Y ") print('Current Date : ' ,dateStr)


String d = "08/30/2018";
LocalDate date = LocalDate.parse(d, DateTimeFormatter.ofPattern("MM/dd/yyyy"));
String newDate = date.format(DateTimeFormatter.ofPattern("MMMM dd, yyyy"));

will print

August 30, 2018

Edit if you want to take into account lower apis, you can do this:

String d = "08/30/2018";
String newDate = "";
    LocalDate date = LocalDate.parse(d, DateTimeFormatter.ofPattern("MM/dd/yyyy"));
    newDate = date.format(DateTimeFormatter.ofPattern("MMMM dd, yyyy"));
} else {
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    Date date = null;
    try {
        date = sdf.parse(d);
        sdf = new SimpleDateFormat("MMMM dd, yyyy");
        newDate = sdf.format(date);
    } catch (ParseException e) {

ParseExact(Convert.ToString(Datetime), "dd/mm/yyyy", CultureInfo.​InvariantCulture)),. Please suggest some code how to convert to 24 May  In this article, you will learn to convert datetime object to its equivalent string in Python with the help of examples. For that, we can use strftime() method. Any object of date, time and datetime can call strftime() to get string from these objects.

For example, you may need to convert a datetime to a string when dealing with server logs or just any time you have a date that needs to be  6 Only supported when casting from character data to datetime or smalldatetime.When casting character data representing only date or only time components to the datetime or smalldatetime data types, the unspecified time component is set to 00:00:00.000, and the unspecified date component is set to 1900-01-01.

Convert.ToDateTime(String), DateTime.Parse() and DateTime.ParseExact() methods for converting a string-based date to a System.DateTime object, Convert​  Required. The value to convert to another data type: style: Optional. The format used to convert between data types, such as a date or string format. Can be one of the following values: Converting datetime to character:

DateString = datestr( t ) converts the datetime values in the input array t to text representing dates  Easy String to DateTime, DateTime to String and formatting Introduction In the few years that I have been a software developer, I have work with plenty of different programming languages.

  • Where is your code? Post it here and let us know what issues you are facing there
  • will you do some effort before asking question
  • @AjayChauhan I did dear friend. Just asking in english is a big one. Thank you for the link, although does not respond my question. Regards
  • It seems that it's requires API level 26, and my current min is 19. Any suggestion?