As the date is in Milli second format, How do i convert it to have a DD/MM/YY format??
Long Ldate = System.currentTimeMillis();
String date = Ldate.toString();
Please use this code. This will help you.
long time = System.currentTimeMillis();
SimpleDateFormat dayTime = new SimpleDateFormat("dd/MM/yy");
String str = dayTime.format(new Date(time));
Related
val dateNow = LocalDateTime.now()
val formatter: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS")
val dateTime = LocalDateTime.parse(it?.LastUpdated, formatter)
println("The date is :" + dateTime)
val duration = Duration.between(dateTime, dateNow).toMinutes()
val countDown = LocalTime.MIN.plus(
Duration.ofMinutes( duration )
).toString()
So I'm pulling LastUpdated using Retrofit then, I'm getting the difference between the two dates and then displaying it in minutes (HH:SS) format.
Let's say, for example, the output of countDown is 24:45.
How can one make that text count down with animation?
I'm trying to parse string date
"AuthDate": "2021-08-19T23:40:52+04:00",
here is code for parsing and displaying
var date = item?.authDate.toString()
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssz")
val parsedDate = formatter.parse(date)
val displayFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd, HH:MM:SS")
text = displayFormatter.format(parsedDate).toString()
This works fine, except one thing, Seconds is always displayed in "00".
For example, if authDate is 2021-08-19T23:40:52+04:00,
displayed authDate is 2021-08-19, 23:40:00
not 23:40:52 as I want.
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssz")
...
val displayFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd, HH:MM:SS")
Notice how the first of these uses mm and ss, while the second uses MM and SS. The former says to parse hours, minutes, then seconds. The latter says to display hours, the month, and then the fraction of a second. See the documentation for a full list of the specifiers, but you're probably looking for
val displayFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd, HH:mm:ss")
How can I convert date from seconds to date format.
I have a table containing information about lat, long and time.
table
f_table['dt'] = pd.to_datetime(f_table['dt'])
f_table["dt"]
it results like this:
output
but the output is wrong actually the date is 20160628 but it converted to 1970.
My desired output:
24-April-2014
The unit needs to be nanoseconds, so you need to multiply with 1e9
f_table['dt'] = pd.to_datetime(f_table['dt'] * 1e9)
This should work.
#Split your string to extract timestamp, I am assuming a single space between each float
op = "28.359062 69.693673 5.204486e+08"
ts = float(op.split()[2])
from datetime import datetime
#Timestamp to datetime object
dt = datetime.fromtimestamp(ts)
#Datetime object to string
dt_str = dt.strftime('%m-%B-%Y')
print(dt_str)
#06-June-1986
How can I check if a date is between two other dates in Groovy? Is there any function like BETWEEN in MySQL?
There isn't any magic function but you can easily write a function to do that
Date date1 = new Date()
Date date2 = new Date().plus(2)
Date toCheck1 = new Date().plus(3)
Date toCheck2 = new Date().plus(1)
def dateBetween(Date date1, Date date2, Date toCheck){
return toCheck.after(date1) && toCheck.before(date2)
}
dateBetween(date1, date2, toCheck1) // returns false
dateBetween(date1, date2, toCheck2) // returns true
The main logic is to convert your date into the format of YYYYMMDD, then you can check if date1 <=date3 <=date2, then you can know if date 3 is between date2 and date1
Below is the code for groovy which can run in soapui. e.g. today is 20171225 an after 5 days its 20171230 . So now 20171227
def date1 = new Date().format("YYYYMMdd")
def date2 = (new Date()+5).format("YYYYMMdd")
def date3 = (new Date()+3).format("YYYYMMdd")
log.info "date1 is " + date1 + " date2 is " + date2 + " date3 is " + date3
if(date2<=date1 && date3>=date1)
{
log.info "date3 is between date1 and date2"
}
else
{
log.info "Date3 is not between date1 and date2"
}
hye, I need to convert date taken from a datefield (J2ME) and convert it to sql date to save in my database, but it's impossible for me to use sql date in j2me
any ideas please
i tried to extract the date
String getDateString(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
int second = calendar.get(Calendar.SECOND);
if(month<10){
return new String(day+"-0"+month+"-"+year+"");}
else
return new String(day+"-"+month+"-"+year+"");
}
then I send it via url
hc = (HttpConnection) Connector.
open(url + "nom=" + tfNom.getString() + "&type=" + myCh.getString(myCh.getSelectedIndex())+ "&date_debut=" + datec + "&date_fin=" + date_fin.getString() );
but in my database i found date 00-00-0000!!