Questions tagged [date-formatting]

Date formatting is the process of displaying, handling or converting a calendar date to a specific format.

Wikipedia goes into good detail about various date formats in its Date format by country article:

Basic components of a calendar date for the most common calendar systems:

Y – Year
M – Month
D – Day

Order of the basic components:

B – Big-endian (year, month, day), e.g. 1996-04-22
L – Little-endian (day, month, year), e.g. 22.04.96 or 22/04/96
M – Middle-endian (month, day, year), e.g. 04/22/96

Specific formats for the basic components

yyyy – Four-digit year, e.g. 1996
yy – Two-digit year, e.g. 96
mm – Two-digit month, e.g. 04
m – one-digit month for months below 10, e.g. 4
mmm – three-letter abbreviation for month
mmmm – month spelled out in full
dd – two-digit day, e.g. 02
d – one-digit day for days below 10, e.g. 2

Separators of the components

"/" – Slash
"." – Dots or full stops
"-" – Hyphens or dashes
" " – Spaces
1459 questions
-4
votes
1 answer

Convertion to java.sql.Date for dd-MMM-yy format

I am doing jdbc and calling a procedure with date parameter but my db tables date format is in dd-MMM-yy format hence i converted my string date into dd-MMM-yy format but I am unable to setDate(1,sdt) cuz sdt must be in java.sql.Date type and…
Arhana
  • 1
  • 2
-4
votes
1 answer

How can I format date and time in golang to use it in neo4j query?

I'm developing a website to learn how to use golang packages: github.com/gin-gonic/gin, and github.com/johnnadratowski/golang-neo4j-bolt-driver. I have a User struct like that type User struct { Id int16 `json:"id" db:"id"` …
Xen Siva
  • 183
  • 1
  • 6
-4
votes
2 answers

Convert String to java.sql.Date object in "YYYY" format

I want to create a java.sql.Date object of the format "YYYY". It should have only the year. I researched a lot but couldn't find a way to do it.
Hazzard
  • 11
  • 8
-4
votes
1 answer

Parse error using Java8 LocalDateTime Iso date format

I use Java 8 New Date variable "LocalDateTime" to convert string in a method: @Override public Object getAsDate(String value) { DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE; return LocalDateTime.parse(value); …
medkhelifi
  • 911
  • 2
  • 9
  • 27
-4
votes
2 answers

Formatting date in Java using SimpleDateFormat

I am trying to parse a date into an appropriate format, but I keep getting the error Unparseable date Can anyone tell me what the mistake is? try { System.out.println(new SimpleDateFormat("d-MMM-Y").parse("05-03-2018").toString()); } catch…
-4
votes
2 answers

SimpleDateFormat is returning date with leading zeros like 0022 Feb 2018

This is my SimpleDateFormat instance: public static final SimpleDateFormat DD_MMM_YYYY = new SimpleDateFormat("dd MMM yyyy"); I'm converting timestamps in milliseconds to this date format. Sometimes it returns the correct date…
-4
votes
1 answer

Java wrong data format transformation

I need a Java program that subtracts 5 years from the current year. Everything is working fine but after I run the program: DateFormat dateFormat = new SimpleDateFormat("yyyy"); Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR,-5); Date…
adama
  • 431
  • 6
  • 20
-4
votes
2 answers

dateformatter producing wrong result on converting datefromstring

My string is strDate:04/12/2016 on converting it to date in format dd/MM/yyyy. It is producing another format.it is producing result as weekEndDate:2016-12-04 00:00:00 +0000. My code is NSDateFormatter *formatter = [[NSDateFormatter alloc]…
niket
  • 27
  • 1
  • 6
-4
votes
6 answers

Create a function that takes string object and returns Date object in dd-MM-yyyy format

I have date in string object. I want to convert into Date object. Date getDateFmString(String dateString) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date convertedCurrentDate = sdf.parse(dateString); return convertedCurrentDate…
shimbu shambu
  • 127
  • 2
  • 10
-4
votes
3 answers

Convert string to specific date format C#

I have a problem to convert string to date format in C#. I'm getting the data through a row of a gridview: string shipping_date = row["Shipping_Date"].ToString(); with format: 27/08/2015 00:00:00 but want convert to the format "yyyyMMdd". Already…
-5
votes
3 answers

java.text.ParseException: Unparseable date: "Augu 16, 1979"

if i try replace("st", "") so it occurs URLjava.text.ParseException: Unparseable date: "Augu 16, 1979" please help .... DateFormat originalFormat = new SimpleDateFormat("MMMM dd, yyyy", Locale.ENGLISH); DateFormat targetFormat = new…
-5
votes
1 answer

How to get the last day of a specific month

I have textbox for inserting date called startdate. What I want is that when the user inserts a date, I should get the last day of month in another textbox. For example:  Startdate: 23/09/2018 "my format is dd/mm/yyyy" Lastdate: 30/09/2018
-5
votes
3 answers

Change a Java date-time string to date

Well I tried to look for many questions but couldn't find something relevant. I have a string that has the following data: String sDate = "2018-01-17 00:00:00"; This comes from an application, and I need to convert it into the following Date…
-5
votes
2 answers

How can I format a GregorianCalendar

I have a GregorianCalendar object. How do I get a formatted string? The line System.out.print("End of rental: " + endDate); produces the following really long calendar. How can I format this down to dd/mm/yyyy? End of rental:…
-6
votes
3 answers

how to convert LocalDate to a specific date time format

how to convert ISO_LOCAL_DATE to date time format : yyyy-MM-dd'T'HH:mm:ss.SSSZ in java Ex: given date: 2016-01-25 to 2016-01-25T00:00:00.000+0100
1 2 3
97
98