How to format LocalDate to string?
I have a LocalDate variable called date,when I print it displays 1988-05-05 I need to convert this to be printed as 05.May 1988.How to do this?
java
add a comment |
I have a LocalDate variable called date,when I print it displays 1988-05-05 I need to convert this to be printed as 05.May 1988.How to do this?
java
3
Take a look at the DateTimeFormatter class. It even has examples of how to convert to and fromString
s.
– azurefrog
Jan 27 '15 at 18:24
2
You should show some code, what you have tried so far and what's not working so people can help you.
– bvidal
Jan 27 '15 at 18:24
I tried to do that but because of this annoying "it does not meet our quality standards" thing I finally gave up,it took me 15 minutes just to post this because i had to correct "i" with "I".
– Jasko
Jan 27 '15 at 18:29
add a comment |
I have a LocalDate variable called date,when I print it displays 1988-05-05 I need to convert this to be printed as 05.May 1988.How to do this?
java
I have a LocalDate variable called date,when I print it displays 1988-05-05 I need to convert this to be printed as 05.May 1988.How to do this?
java
java
asked Jan 27 '15 at 18:21
JaskoJasko
565147
565147
3
Take a look at the DateTimeFormatter class. It even has examples of how to convert to and fromString
s.
– azurefrog
Jan 27 '15 at 18:24
2
You should show some code, what you have tried so far and what's not working so people can help you.
– bvidal
Jan 27 '15 at 18:24
I tried to do that but because of this annoying "it does not meet our quality standards" thing I finally gave up,it took me 15 minutes just to post this because i had to correct "i" with "I".
– Jasko
Jan 27 '15 at 18:29
add a comment |
3
Take a look at the DateTimeFormatter class. It even has examples of how to convert to and fromString
s.
– azurefrog
Jan 27 '15 at 18:24
2
You should show some code, what you have tried so far and what's not working so people can help you.
– bvidal
Jan 27 '15 at 18:24
I tried to do that but because of this annoying "it does not meet our quality standards" thing I finally gave up,it took me 15 minutes just to post this because i had to correct "i" with "I".
– Jasko
Jan 27 '15 at 18:29
3
3
Take a look at the DateTimeFormatter class. It even has examples of how to convert to and from
String
s.– azurefrog
Jan 27 '15 at 18:24
Take a look at the DateTimeFormatter class. It even has examples of how to convert to and from
String
s.– azurefrog
Jan 27 '15 at 18:24
2
2
You should show some code, what you have tried so far and what's not working so people can help you.
– bvidal
Jan 27 '15 at 18:24
You should show some code, what you have tried so far and what's not working so people can help you.
– bvidal
Jan 27 '15 at 18:24
I tried to do that but because of this annoying "it does not meet our quality standards" thing I finally gave up,it took me 15 minutes just to post this because i had to correct "i" with "I".
– Jasko
Jan 27 '15 at 18:29
I tried to do that but because of this annoying "it does not meet our quality standards" thing I finally gave up,it took me 15 minutes just to post this because i had to correct "i" with "I".
– Jasko
Jan 27 '15 at 18:29
add a comment |
7 Answers
7
active
oldest
votes
SimpleDateFormat will not work if he is starting with LocalDate which is new in Java 8. From what I can see, you will have to use DateTimeFormatter, http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html.
LocalDate localDate = LocalDate.now();//For reference
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd LLLL yyyy");
String formattedString = localDate.format(formatter);
That should print 05 May 1988. To get the period after the day and before the month, you might have to use "dd'.LLLL yyyy"
3
Thank you very much,this helps,but it didn't work with 'LLLL' to show name of the month but with 'MMMM' i found this strange since even in the documentation it says otherwise.But once again thank you for helping me.
– Jasko
Jan 27 '15 at 19:17
1
Now localDate.format(formatter); doesn't work at all
– Tot
Dec 10 '16 at 3:12
which version JDK your Using @ProgrammersBlock
– Lova Chittumuri
Jan 31 '18 at 11:44
add a comment |
Could be short as:
LocalDate.now().format(
DateTimeFormatter.ofPattern("dd/MM/yyyy"));
add a comment |
System.out.println(LocalDate.now().format(DateTimeFormatter.ofPattern("dd.MMMM yyyy")));
The above answer shows it for today
add a comment |
With the help of ProgrammersBlock posts I came up with this. My needs were slightly different. I needed to take a string and return it as a LocalDate object. I was handed code that was using the older Calendar and SimpleDateFormat. I wanted to make it a little more current. This is what I came up with.
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
void ExampleFormatDate() {
LocalDate formattedDate = null; //Declare LocalDate variable to receive the formatted date.
DateTimeFormatter dateTimeFormatter; //Declare date formatter
String rawDate = "2000-01-01"; //Test string that holds a date to format and parse.
dateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE;
//formattedDate.parse(String string) wraps the String.format(String string, DateTimeFormatter format) method.
//First, the rawDate string is formatted according to DateTimeFormatter. Second, that formatted string is parsed into
//the LocalDate formattedDate object.
formattedDate = formattedDate.parse(String.format(rawDate, dateTimeFormatter));
}
Hopefully this will help someone, if anyone sees a better way of doing this task please add your input.
add a comment |
LocalDate.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy").toString())
Ex. You can use any kind of date pattern
1. dd/MM/yyyy
2. dd/MM/yy
3. yyyy/MM/dd
add a comment |
LocalDate date = LocalDate.now();//For reference
System.out.println(DateTimeFormat.longDate().print(date));
System.out.println(date.toString("dd.MMMM YYYY"));
Beware, language of month depends of locale or something.
see more
add a comment |
A pretty nice way to do this is to use SimpleDateFormat
I'll show you how:
SimpleDateFormat sdf = new SimpleDateFormat("d MMMM YYYY");
Date d = new Date();
sdf.format(d);
I see that you have the date in a variable:
sdf.format(variable_name);
Cheers.
1
SimpleDateFormat
can work withLocalDate
?
– Tom
Jan 27 '15 at 18:30
What do you mean by 'can work with'?
– nom
Jan 27 '15 at 18:32
2
OP wants to print the content of aLocalDate
instance in a specific format. How couldSimpleDateFormat
help him here?
– Tom
Jan 27 '15 at 18:34
From what I know, LocalDate is already formatted....
– nom
Jan 27 '15 at 18:38
@jasko: Use: Date dt = sdf.format(varName);
– nom
Jan 27 '15 at 18:40
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f28177370%2fhow-to-format-localdate-to-string%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
SimpleDateFormat will not work if he is starting with LocalDate which is new in Java 8. From what I can see, you will have to use DateTimeFormatter, http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html.
LocalDate localDate = LocalDate.now();//For reference
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd LLLL yyyy");
String formattedString = localDate.format(formatter);
That should print 05 May 1988. To get the period after the day and before the month, you might have to use "dd'.LLLL yyyy"
3
Thank you very much,this helps,but it didn't work with 'LLLL' to show name of the month but with 'MMMM' i found this strange since even in the documentation it says otherwise.But once again thank you for helping me.
– Jasko
Jan 27 '15 at 19:17
1
Now localDate.format(formatter); doesn't work at all
– Tot
Dec 10 '16 at 3:12
which version JDK your Using @ProgrammersBlock
– Lova Chittumuri
Jan 31 '18 at 11:44
add a comment |
SimpleDateFormat will not work if he is starting with LocalDate which is new in Java 8. From what I can see, you will have to use DateTimeFormatter, http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html.
LocalDate localDate = LocalDate.now();//For reference
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd LLLL yyyy");
String formattedString = localDate.format(formatter);
That should print 05 May 1988. To get the period after the day and before the month, you might have to use "dd'.LLLL yyyy"
3
Thank you very much,this helps,but it didn't work with 'LLLL' to show name of the month but with 'MMMM' i found this strange since even in the documentation it says otherwise.But once again thank you for helping me.
– Jasko
Jan 27 '15 at 19:17
1
Now localDate.format(formatter); doesn't work at all
– Tot
Dec 10 '16 at 3:12
which version JDK your Using @ProgrammersBlock
– Lova Chittumuri
Jan 31 '18 at 11:44
add a comment |
SimpleDateFormat will not work if he is starting with LocalDate which is new in Java 8. From what I can see, you will have to use DateTimeFormatter, http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html.
LocalDate localDate = LocalDate.now();//For reference
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd LLLL yyyy");
String formattedString = localDate.format(formatter);
That should print 05 May 1988. To get the period after the day and before the month, you might have to use "dd'.LLLL yyyy"
SimpleDateFormat will not work if he is starting with LocalDate which is new in Java 8. From what I can see, you will have to use DateTimeFormatter, http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html.
LocalDate localDate = LocalDate.now();//For reference
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd LLLL yyyy");
String formattedString = localDate.format(formatter);
That should print 05 May 1988. To get the period after the day and before the month, you might have to use "dd'.LLLL yyyy"
edited Jan 27 '15 at 19:09
answered Jan 27 '15 at 19:03
ProgrammersBlockProgrammersBlock
2,96131316
2,96131316
3
Thank you very much,this helps,but it didn't work with 'LLLL' to show name of the month but with 'MMMM' i found this strange since even in the documentation it says otherwise.But once again thank you for helping me.
– Jasko
Jan 27 '15 at 19:17
1
Now localDate.format(formatter); doesn't work at all
– Tot
Dec 10 '16 at 3:12
which version JDK your Using @ProgrammersBlock
– Lova Chittumuri
Jan 31 '18 at 11:44
add a comment |
3
Thank you very much,this helps,but it didn't work with 'LLLL' to show name of the month but with 'MMMM' i found this strange since even in the documentation it says otherwise.But once again thank you for helping me.
– Jasko
Jan 27 '15 at 19:17
1
Now localDate.format(formatter); doesn't work at all
– Tot
Dec 10 '16 at 3:12
which version JDK your Using @ProgrammersBlock
– Lova Chittumuri
Jan 31 '18 at 11:44
3
3
Thank you very much,this helps,but it didn't work with 'LLLL' to show name of the month but with 'MMMM' i found this strange since even in the documentation it says otherwise.But once again thank you for helping me.
– Jasko
Jan 27 '15 at 19:17
Thank you very much,this helps,but it didn't work with 'LLLL' to show name of the month but with 'MMMM' i found this strange since even in the documentation it says otherwise.But once again thank you for helping me.
– Jasko
Jan 27 '15 at 19:17
1
1
Now localDate.format(formatter); doesn't work at all
– Tot
Dec 10 '16 at 3:12
Now localDate.format(formatter); doesn't work at all
– Tot
Dec 10 '16 at 3:12
which version JDK your Using @ProgrammersBlock
– Lova Chittumuri
Jan 31 '18 at 11:44
which version JDK your Using @ProgrammersBlock
– Lova Chittumuri
Jan 31 '18 at 11:44
add a comment |
Could be short as:
LocalDate.now().format(
DateTimeFormatter.ofPattern("dd/MM/yyyy"));
add a comment |
Could be short as:
LocalDate.now().format(
DateTimeFormatter.ofPattern("dd/MM/yyyy"));
add a comment |
Could be short as:
LocalDate.now().format(
DateTimeFormatter.ofPattern("dd/MM/yyyy"));
Could be short as:
LocalDate.now().format(
DateTimeFormatter.ofPattern("dd/MM/yyyy"));
edited Nov 15 '18 at 14:12
answered Sep 23 '18 at 14:38
ZonZon
5,33544153
5,33544153
add a comment |
add a comment |
System.out.println(LocalDate.now().format(DateTimeFormatter.ofPattern("dd.MMMM yyyy")));
The above answer shows it for today
add a comment |
System.out.println(LocalDate.now().format(DateTimeFormatter.ofPattern("dd.MMMM yyyy")));
The above answer shows it for today
add a comment |
System.out.println(LocalDate.now().format(DateTimeFormatter.ofPattern("dd.MMMM yyyy")));
The above answer shows it for today
System.out.println(LocalDate.now().format(DateTimeFormatter.ofPattern("dd.MMMM yyyy")));
The above answer shows it for today
edited Aug 8 '18 at 18:54
answered Aug 8 '18 at 18:41
karthik rkarthik r
19735
19735
add a comment |
add a comment |
With the help of ProgrammersBlock posts I came up with this. My needs were slightly different. I needed to take a string and return it as a LocalDate object. I was handed code that was using the older Calendar and SimpleDateFormat. I wanted to make it a little more current. This is what I came up with.
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
void ExampleFormatDate() {
LocalDate formattedDate = null; //Declare LocalDate variable to receive the formatted date.
DateTimeFormatter dateTimeFormatter; //Declare date formatter
String rawDate = "2000-01-01"; //Test string that holds a date to format and parse.
dateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE;
//formattedDate.parse(String string) wraps the String.format(String string, DateTimeFormatter format) method.
//First, the rawDate string is formatted according to DateTimeFormatter. Second, that formatted string is parsed into
//the LocalDate formattedDate object.
formattedDate = formattedDate.parse(String.format(rawDate, dateTimeFormatter));
}
Hopefully this will help someone, if anyone sees a better way of doing this task please add your input.
add a comment |
With the help of ProgrammersBlock posts I came up with this. My needs were slightly different. I needed to take a string and return it as a LocalDate object. I was handed code that was using the older Calendar and SimpleDateFormat. I wanted to make it a little more current. This is what I came up with.
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
void ExampleFormatDate() {
LocalDate formattedDate = null; //Declare LocalDate variable to receive the formatted date.
DateTimeFormatter dateTimeFormatter; //Declare date formatter
String rawDate = "2000-01-01"; //Test string that holds a date to format and parse.
dateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE;
//formattedDate.parse(String string) wraps the String.format(String string, DateTimeFormatter format) method.
//First, the rawDate string is formatted according to DateTimeFormatter. Second, that formatted string is parsed into
//the LocalDate formattedDate object.
formattedDate = formattedDate.parse(String.format(rawDate, dateTimeFormatter));
}
Hopefully this will help someone, if anyone sees a better way of doing this task please add your input.
add a comment |
With the help of ProgrammersBlock posts I came up with this. My needs were slightly different. I needed to take a string and return it as a LocalDate object. I was handed code that was using the older Calendar and SimpleDateFormat. I wanted to make it a little more current. This is what I came up with.
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
void ExampleFormatDate() {
LocalDate formattedDate = null; //Declare LocalDate variable to receive the formatted date.
DateTimeFormatter dateTimeFormatter; //Declare date formatter
String rawDate = "2000-01-01"; //Test string that holds a date to format and parse.
dateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE;
//formattedDate.parse(String string) wraps the String.format(String string, DateTimeFormatter format) method.
//First, the rawDate string is formatted according to DateTimeFormatter. Second, that formatted string is parsed into
//the LocalDate formattedDate object.
formattedDate = formattedDate.parse(String.format(rawDate, dateTimeFormatter));
}
Hopefully this will help someone, if anyone sees a better way of doing this task please add your input.
With the help of ProgrammersBlock posts I came up with this. My needs were slightly different. I needed to take a string and return it as a LocalDate object. I was handed code that was using the older Calendar and SimpleDateFormat. I wanted to make it a little more current. This is what I came up with.
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
void ExampleFormatDate() {
LocalDate formattedDate = null; //Declare LocalDate variable to receive the formatted date.
DateTimeFormatter dateTimeFormatter; //Declare date formatter
String rawDate = "2000-01-01"; //Test string that holds a date to format and parse.
dateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE;
//formattedDate.parse(String string) wraps the String.format(String string, DateTimeFormatter format) method.
//First, the rawDate string is formatted according to DateTimeFormatter. Second, that formatted string is parsed into
//the LocalDate formattedDate object.
formattedDate = formattedDate.parse(String.format(rawDate, dateTimeFormatter));
}
Hopefully this will help someone, if anyone sees a better way of doing this task please add your input.
answered Feb 25 '18 at 18:40
PkinPkin
112
112
add a comment |
add a comment |
LocalDate.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy").toString())
Ex. You can use any kind of date pattern
1. dd/MM/yyyy
2. dd/MM/yy
3. yyyy/MM/dd
add a comment |
LocalDate.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy").toString())
Ex. You can use any kind of date pattern
1. dd/MM/yyyy
2. dd/MM/yy
3. yyyy/MM/dd
add a comment |
LocalDate.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy").toString())
Ex. You can use any kind of date pattern
1. dd/MM/yyyy
2. dd/MM/yy
3. yyyy/MM/dd
LocalDate.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy").toString())
Ex. You can use any kind of date pattern
1. dd/MM/yyyy
2. dd/MM/yy
3. yyyy/MM/dd
answered Dec 13 '18 at 7:27
Pavan TPavan T
329310
329310
add a comment |
add a comment |
LocalDate date = LocalDate.now();//For reference
System.out.println(DateTimeFormat.longDate().print(date));
System.out.println(date.toString("dd.MMMM YYYY"));
Beware, language of month depends of locale or something.
see more
add a comment |
LocalDate date = LocalDate.now();//For reference
System.out.println(DateTimeFormat.longDate().print(date));
System.out.println(date.toString("dd.MMMM YYYY"));
Beware, language of month depends of locale or something.
see more
add a comment |
LocalDate date = LocalDate.now();//For reference
System.out.println(DateTimeFormat.longDate().print(date));
System.out.println(date.toString("dd.MMMM YYYY"));
Beware, language of month depends of locale or something.
see more
LocalDate date = LocalDate.now();//For reference
System.out.println(DateTimeFormat.longDate().print(date));
System.out.println(date.toString("dd.MMMM YYYY"));
Beware, language of month depends of locale or something.
see more
edited Jan 26 '17 at 15:51
answered Jan 20 '17 at 13:52
SVK PETOSVK PETO
14
14
add a comment |
add a comment |
A pretty nice way to do this is to use SimpleDateFormat
I'll show you how:
SimpleDateFormat sdf = new SimpleDateFormat("d MMMM YYYY");
Date d = new Date();
sdf.format(d);
I see that you have the date in a variable:
sdf.format(variable_name);
Cheers.
1
SimpleDateFormat
can work withLocalDate
?
– Tom
Jan 27 '15 at 18:30
What do you mean by 'can work with'?
– nom
Jan 27 '15 at 18:32
2
OP wants to print the content of aLocalDate
instance in a specific format. How couldSimpleDateFormat
help him here?
– Tom
Jan 27 '15 at 18:34
From what I know, LocalDate is already formatted....
– nom
Jan 27 '15 at 18:38
@jasko: Use: Date dt = sdf.format(varName);
– nom
Jan 27 '15 at 18:40
add a comment |
A pretty nice way to do this is to use SimpleDateFormat
I'll show you how:
SimpleDateFormat sdf = new SimpleDateFormat("d MMMM YYYY");
Date d = new Date();
sdf.format(d);
I see that you have the date in a variable:
sdf.format(variable_name);
Cheers.
1
SimpleDateFormat
can work withLocalDate
?
– Tom
Jan 27 '15 at 18:30
What do you mean by 'can work with'?
– nom
Jan 27 '15 at 18:32
2
OP wants to print the content of aLocalDate
instance in a specific format. How couldSimpleDateFormat
help him here?
– Tom
Jan 27 '15 at 18:34
From what I know, LocalDate is already formatted....
– nom
Jan 27 '15 at 18:38
@jasko: Use: Date dt = sdf.format(varName);
– nom
Jan 27 '15 at 18:40
add a comment |
A pretty nice way to do this is to use SimpleDateFormat
I'll show you how:
SimpleDateFormat sdf = new SimpleDateFormat("d MMMM YYYY");
Date d = new Date();
sdf.format(d);
I see that you have the date in a variable:
sdf.format(variable_name);
Cheers.
A pretty nice way to do this is to use SimpleDateFormat
I'll show you how:
SimpleDateFormat sdf = new SimpleDateFormat("d MMMM YYYY");
Date d = new Date();
sdf.format(d);
I see that you have the date in a variable:
sdf.format(variable_name);
Cheers.
answered Jan 27 '15 at 18:29
nomnom
174314
174314
1
SimpleDateFormat
can work withLocalDate
?
– Tom
Jan 27 '15 at 18:30
What do you mean by 'can work with'?
– nom
Jan 27 '15 at 18:32
2
OP wants to print the content of aLocalDate
instance in a specific format. How couldSimpleDateFormat
help him here?
– Tom
Jan 27 '15 at 18:34
From what I know, LocalDate is already formatted....
– nom
Jan 27 '15 at 18:38
@jasko: Use: Date dt = sdf.format(varName);
– nom
Jan 27 '15 at 18:40
add a comment |
1
SimpleDateFormat
can work withLocalDate
?
– Tom
Jan 27 '15 at 18:30
What do you mean by 'can work with'?
– nom
Jan 27 '15 at 18:32
2
OP wants to print the content of aLocalDate
instance in a specific format. How couldSimpleDateFormat
help him here?
– Tom
Jan 27 '15 at 18:34
From what I know, LocalDate is already formatted....
– nom
Jan 27 '15 at 18:38
@jasko: Use: Date dt = sdf.format(varName);
– nom
Jan 27 '15 at 18:40
1
1
SimpleDateFormat
can work with LocalDate
?– Tom
Jan 27 '15 at 18:30
SimpleDateFormat
can work with LocalDate
?– Tom
Jan 27 '15 at 18:30
What do you mean by 'can work with'?
– nom
Jan 27 '15 at 18:32
What do you mean by 'can work with'?
– nom
Jan 27 '15 at 18:32
2
2
OP wants to print the content of a
LocalDate
instance in a specific format. How could SimpleDateFormat
help him here?– Tom
Jan 27 '15 at 18:34
OP wants to print the content of a
LocalDate
instance in a specific format. How could SimpleDateFormat
help him here?– Tom
Jan 27 '15 at 18:34
From what I know, LocalDate is already formatted....
– nom
Jan 27 '15 at 18:38
From what I know, LocalDate is already formatted....
– nom
Jan 27 '15 at 18:38
@jasko: Use: Date dt = sdf.format(varName);
– nom
Jan 27 '15 at 18:40
@jasko: Use: Date dt = sdf.format(varName);
– nom
Jan 27 '15 at 18:40
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f28177370%2fhow-to-format-localdate-to-string%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Take a look at the DateTimeFormatter class. It even has examples of how to convert to and from
String
s.– azurefrog
Jan 27 '15 at 18:24
2
You should show some code, what you have tried so far and what's not working so people can help you.
– bvidal
Jan 27 '15 at 18:24
I tried to do that but because of this annoying "it does not meet our quality standards" thing I finally gave up,it took me 15 minutes just to post this because i had to correct "i" with "I".
– Jasko
Jan 27 '15 at 18:29