srikotesh
asked on
how to get last 7days starting time stamp and ending time stamp in java
Hi Experts,
I want to get last one week timestamp
Example:
current date :2015/08/05
now i want to get the time stamp for last 7days
2015/07/29--->starttime 1438128010 endtime 1438214399
2015/07/30--->starttime 1438214400 endtime 1438300799
---
--
--
2015/08/05--->starttime 1438732800 endtime 1438819199
i dont want date i need only timestamp starttime and endtime
for last one week whenver i call this method.
can some suggest me how to do
Thanks,
I want to get last one week timestamp
Example:
current date :2015/08/05
now i want to get the time stamp for last 7days
2015/07/29--->starttime 1438128010 endtime 1438214399
2015/07/30--->starttime 1438214400 endtime 1438300799
---
--
--
2015/08/05--->starttime 1438732800 endtime 1438819199
i dont want date i need only timestamp starttime and endtime
for last one week whenver i call this method.
can some suggest me how to do
Thanks,
ASKER
Hi Doug,
i need 1 week timestamps
as i mentioned if i give date as 2015/08/6
my code has to get the last one week timestamps
start time to endtime
from 2015/07/29 to 2015/08/06 .
date should be dynamic.
we can give any date it has to fetch last 7days time stamps
i need 1 week timestamps
as i mentioned if i give date as 2015/08/6
my code has to get the last one week timestamps
start time to endtime
from 2015/07/29 to 2015/08/06 .
date should be dynamic.
we can give any date it has to fetch last 7days time stamps
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ooh Java 8 is cool :)
Doug
Doug
ASKER
Hi Doug,
I am getting the expected output.
i remove gmt timezone.
HI CEHJ,
thanks for giving this code java8.
i got this output:
1438387200000->14384736000 00
1438473600000->14385600000 00
1438560000000->14386464000 00
1438646400000->14387328000 00
1438732800000->14388192000 00
1438819200000->14389056000 00
1438905600000->14389920000 00
when i converted this to date i got like this
1438905600000--->8/7/2015, 5:30:00 AM
is it possible to change -->8/7/2015, 12:00:00 AM
1438992000000--->8/7/2015, 11:59:59 PM
I am getting the expected output.
i remove gmt timezone.
HI CEHJ,
thanks for giving this code java8.
i got this output:
1438387200000->14384736000
1438473600000->14385600000
1438560000000->14386464000
1438646400000->14387328000
1438732800000->14388192000
1438819200000->14389056000
1438905600000->14389920000
when i converted this to date i got like this
1438905600000--->8/7/2015,
is it possible to change -->8/7/2015, 12:00:00 AM
1438992000000--->8/7/2015,
ASKER
Hi Experts,
apart from the time stamp i need name of a day.
Example:
Monday-->starttime--->1438 387200000 endtime->1438473600000
Tuesday-->starttime--->143 8473600000 endtime->1438560000000
---
sunday
can some one suggest me how to do this one as well.
apart from the time stamp i need name of a day.
Example:
Monday-->starttime--->1438
Tuesday-->starttime--->143
---
sunday
can some one suggest me how to do this one as well.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
getting expected output:
Saturday Start 1438367400 End 1438453799
Sunday Start 1438453800 End 1438540199
Monday Start 1438540200 End 1438626599
Saturday Start 1438367400 End 1438453799
Sunday Start 1438453800 End 1438540199
Monday Start 1438540200 End 1438626599
Good.
ASKER
Excellent
Open in new window
(I took off 1 second from 7 days as you appear to want 11:59:59 at the end).
Also dividing the final results by 1000 as these timestamps are in milliseconds and you appear to want the seconds version.
Doug