Questions tagged [simpledateformat]
SimpleDateFormat is a concrete Java class for formatting and parsing dates and times in a locale-sensitive manner. It allows for formatting (date -> text), parsing (text -> date), and normalization.
2,579
questions
-2
votes
2
answers
58
views
How can I calculate, How much time is left before tomorrow? [closed]
How can I calculate and format time like HH:mm, Of much time is left before tomorrow? with SimpleDateFormat.
0
votes
2
answers
64
views
Change Date Format Java
I am using this code :
final String OLD_FORMAT = "dd-MMM-yy";
final String NEW_FORMAT = "dd/MM/yyyy";
String oldDateString = "16-OCT-19";
String newDateString;
...
-2
votes
1
answer
62
views
converting string to Date like this "yyyy-MM-dd" format [duplicate]
I am trying to convert string to Date, but I am not able to get the format that I want.
My code goes like this:
String inputDate ="1948-06-29";
SimpleDateFormat simpleDate = new ...
0
votes
2
answers
63
views
Date input being output as null [closed]
I get my output as null when I input date as String
this is the get and set
public Date getData(){
return data;
}
public void setData(String dataRecebida) {
try {
this.data = formatter....
0
votes
1
answer
63
views
Java - format Date only with slash based on locale
My code is
ZonedDateTime zoned = ZonedDateTime.now();
DateTimeFormatter pattern = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).withLocale(Locale.forLanguageTag("ja-JP"));
System.out....
0
votes
1
answer
31
views
Parsing date crashes in Android 12 [duplicate]
I am using the following code to parse date to sort a list:
Collections.sort(collaborationRoomModelList, new Comparator<CollaborationRoomModel>() {
DateFormat f = new ...
0
votes
0
answers
34
views
Java parse date from string including -th day of month [duplicate]
On the web site I'm working with the dates object is created are presented in format like:
Jun 8th 2022 16:31:22
I need to validate the creation date is within the last 5 minutes.
So, I can get the ...
0
votes
0
answers
56
views
Java: Formatting a Date inside of a string
I know I'm probably doing something wrong, but I am trying to format a Date that is currently stored inside of a string but it won't let me parse it to a String because it doesn't recognize it as a ...
0
votes
2
answers
24
views
How to format a UTC string as MMMM dd, yyyy in Javascript for kore.ai
The string I have : 2021-11-02T00:00:00.000Z .
I need to display this as November 02, 2021.
Could someone please help me with this?
0
votes
0
answers
53
views
Caused by: java.text.ParseException: Unparseable date: "2015-06-18T23:30:00.000Z"
I'm trying to format a date and then convert it to a local time , by upon trying it keeps throwing an exception that the data is unparsable , i have attached the code below , if anyone could help , ...
-1
votes
1
answer
58
views
Kotlin extract time form the date
I have a date with that format: 2027-02-14T14:20:00.000
I would like to take hours and minutes from it like in that case: 14:20
I was trying to do something like this:
val firstDate = SimpleDateFormat(...
0
votes
1
answer
64
views
Java dates zone format to simple format
is it possible to convert this kind of format in Java (probably ISO 8601) "2022-11-11T00:00:00" or this "2022-11-11T12:00:00+01:00" which comes as a string, to simple format "...
0
votes
1
answer
37
views
Java date parsing has stranger behavior where parsing different date in different timezone
Here I am trying to parse two dates in java. Date 1 is "2021-01-01" and date 2 is "2021-04-01". But after parsing Java generating Date object with a different timezone. Really ...
0
votes
0
answers
63
views
SimpleDateFormat is missing short and long time patterns
Is there a reason why SimpleDateFormat has no "t" and "T" similar to c#?
For example if you want to have a custom format and not worry about 24hour or 12am/pm formats; also Egypt ...
0
votes
2
answers
46
views
Is this the best practice for SimpleDateFormat in spring boot?
The SimpleDateFormat is not a thread-safe class.
Is this the best practice to write a Utility Service for SimpleDateFormat in spring boot?
@Service
public class DateConvertUtil {
private ...
1
vote
1
answer
45
views
Dealing with SimpleDateFormat passed in RequestBody
I'm developing a simple REST Controller. I'm receiving a SimpleDateFormat object in Request body. Looks like that:
2014-04-13T03:42:06-02:00
My current method now is:
@PostMapping
public ...
0
votes
2
answers
49
views
How to get date from json response and attached to recycleView Adapter by extracting date,month,year and attach to textview
I am getting json response in date format 2022-03-25T00:00:00.000Z I want get day , month and year seperately and attach in text view in recycler view kotlin.
0
votes
0
answers
55
views
why Java date formatter ignores seconds, milliseconds and time zone information while parsing date
I am very confused in the below code. Even after passing the correct dateformat for parsing the entire date, time and timezone, why java is ignoring the information beyond minutes.
I have a list of ...
-1
votes
1
answer
79
views
SimpleDateFormat fails to parse date format in MM/dd/yy
We have an application where we are parsing date in MM/dd/yy format which works fine for any date upto 2042. But problem occurs when we select date as 2099 which defaults to 1999. Is there any way we ...
0
votes
1
answer
199
views
Parse String date of format yyyy-MM-dd to java.util.Date of format yyyy-MM-dd
We are using Java8 in our project.I have startDate in String format "2021-12-31" which I am receiving from from an 3RD party.
I have to pass it to our consumer via our model.Model ...
4
votes
1
answer
133
views
SimpleDateFormat fails on particular date
On java 1.8 this code fails
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
dateFormat.setLenient(false);
dateFormat.setTimeZone(TimeZone.getTimeZone("America/...
0
votes
0
answers
79
views
Simple Date Format DateTime gives different result in different android devices
fun getDateTimeWithUTC(): String {
val df = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
df.timeZone = TimeZone.getTimeZone("UTC")
return df.format(Date())
}
this code gives ...
-1
votes
1
answer
62
views
SimpleDateFormat returns wrong date in java
private String dateFormatter(String olddate) {
String newDate = "";
try {
SimpleDateFormat initDate = new SimpleDateFormat("dd-MMM-yy - HH:mm");
...
0
votes
0
answers
26
views
How to convert LocalTime to RegularTimePeriod? [duplicate]
I am plotting a linechart with JFreeChart. X axis of the linechart should be time and I want to get this time as a string like "08:20:20,19". When I am trying to convert LocalTime to ...
-1
votes
2
answers
67
views
Compare between two dates with time and timezone [closed]
I am developing a login functionality, where user is not allowed to login between some duration of time, and this is configurable.
For example user is not allowed to login between
{
"fromDate&...
0
votes
0
answers
23
views
Setting time in JXDatePicker
I'm using JXDatePicker for displaying and selecting Date and Time.
But I want to set the Date and Time to the current Date and time. Setting Date works, but I can't find a way to set a time, please ...
-1
votes
1
answer
17
views
How I can output time through SimpledateFormat correctly? [duplicate]
I have Java Swing application. And in this application time/data is outputed every step. But it outputs data/time without numbers changes.
enter image description here
private static Date now = new ...
0
votes
0
answers
26
views
Creating Kotlin time format depends on language
How can I generate something like this: "1h 43min" but depends on the language (local) in Kotlin?
So for English, it will be 1h 43min, for german 1z 43min, etc.
-2
votes
1
answer
915
views
Convert string timestamp "yyyy-mm-dd'T'HH:mm:ss.SSS+ZZ:ZZ" to string timestamp "yyyy-mm-dd'T'HH:mm:ss.SSSZ" [duplicate]
For example, if I have the string timestamp 2022-01-12T19:41:27.000+00:00, I would like to get 2022-01-12T19:41:27.000Z.
I would like to ensure that I come with a solution that can in the future take ...
0
votes
1
answer
31
views
SimpleDateFormat Java
I need the DATE_FORMAT for this case: "Thu Feb 17 08:50:02 UTC 2022"
The example code is this:
date = new SimpleDateFormat(DATE_FORMAT).parse(s);
where DATE_FORMAT is the format that I need ...
0
votes
1
answer
88
views
Java SimpleDateFormat Cannot format given Object as a Date
I am trying to convert string to date using date format and used the following code but its shows an error.
public static Date ConvertStringtodate(String Date) throws ParseException {
...
0
votes
2
answers
32
views
What is the alternative for getMonthValue(),getDayOfMonth() in java 7?
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS");
Date date = new Date();
How Do I make this Java 7 compatible? What changes should I do?
String part = ...
0
votes
0
answers
48
views
I am getting different day of the week for the same date [duplicate]
I was trying to do a question where I have to print the name of the weekday. At first, i tried using this method:
My program
public static String findDay(int month, int day, int year){
...
0
votes
1
answer
28
views
How to parse "2022-02-04T12:20:47,398000+01" into SimpleDateFormat?
My date string looks like this "2022-02-04T12:20:47,398000+01".
I tried this format SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss,SSSSSSZ") but it throws an exception.
Minimum API level ...
0
votes
1
answer
140
views
How do I convert String to Instant concatenating a date string to a time string?
I need to convert this String to a Instant, i do it this way:
String inputStartDate = startDate+" 00:00:00.000";
String inputEndDate = endDate+" 23:59:59.999";
startDate is only ...
1
vote
1
answer
62
views
Hive - How to extract dats from a string with different formats
Hi iam trying to extract dates from the string using regex function.How to extract dates dynamically when the date format changes from mm/dd/yyyy to mm/dd/yy. The below regexp works for mm/dd/yyyy ...
-2
votes
2
answers
72
views
How to parse this date in java?
how to parse this date format in java?
2022-01-19T18:14:17+03:00
I tried SimpleDateFormat("yyyy-MM-dd HH:mm:ssz"), but it didn't work.
1
vote
3
answers
86
views
when hour = 12,it parses to 00, why?
When I'm going to get a long with new Date().getTime(), I find that when time > 11:59:59, it always resolve 00:xx:xx, for example; 12:00:00 --> 00:00:00, 12:23:56 --> 00:23:56;
...
1
vote
1
answer
57
views
SimpleDateFormat returning the wrong date in Java
I'm having an issue with SimpleDateFormat in Java. My code is returning the wrong date. Help please.
String date_str = "Tue Mar 08 09:44:55 EST 2022";
Date date = new SimpleDateFormat(&...
-1
votes
1
answer
34
views
java convert string pattern to date
how to convert string to date in java , i have such string that i get from database
Aug 12, 2011, 8:17:46 PM
i used different SimpleDateFormat but i can't convert it , i am getting
java.text....
-3
votes
1
answer
83
views
SimpleDateFormat seems to allow a year of yy when the format is set to dd/mm/yyyy [closed]
If I have this:
private static final String DATE_FORMAT = "dd/MM/yyyy";
DateFormat formatter = new SimpleDateFormat(DATE_FORMAT);
formatter.setLenient(false);
formatter.parse("01/01/98&...
2
votes
0
answers
247
views
JDK-11 introducing comma in date format
I have following method that generates the date in Jan 3, 2022 9:06:16 PM format when runs on JDK-8. However, as soon as I changed my jdk to JDK-11, it generates the date in format Jan 3, 2022, 9:12:...
0
votes
0
answers
35
views
How to parse an Integer for SimpleDateFormat()
I want to show the Integer "zeitMinuten" and "zeitStunden" in my TextView with the "mm" and "HH" Format.
Now my TextView is just "00". When I just do &...
2
votes
1
answer
87
views
How to get Google spreadsheet time zone offset string instead of timezone string?
Google sheet spreadsheet have a time zone setting viewed via the File -> Settings menu. see image.
However following code line
SpreadsheetApp.getActive().getSpreadsheetTimeZone();
returns: ...
0
votes
2
answers
108
views
SimpleDateFormat parse not giving the response I expected
I have this Java class:
package TestPackage;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class TestSimpleDateFormat {
private static ...
1
vote
1
answer
275
views
SimpleDateFormat vs DateTimeFormatter
I have a use case where I have to compare 2 string dates such as
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(dateFormat.parse("2019-07-07&...
1
vote
0
answers
68
views
SimpleDateFormat in Java giving inconsistent results
I have a class as
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.experimental.FieldDefaults;
import lombok.extern.slf4j.Slf4j;
import java.text.ParseException;
import java....
-1
votes
3
answers
83
views
Java Changing date format for a specific day
I want to write today's date in the following format using SimpleDateFormat:
Today, 13:14
On other days, I want to print it as date and time:
06.12.2021, 12:59
I can write in date and time format for ...
-1
votes
1
answer
120
views
How to convert API date to string in Kotlin within my recyclerview adapter?
I need to convert API date from this (yyyy-MM-dd HH:mm:ss) format to (oct 18) like this
@Throws(ParseException::class)
private fun getFormate(date: String): String? {
val d: Date = ...