Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
xabber-android
Commits
bca36b8c
Commit
bca36b8c
authored
Feb 19, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StringUtils: time format changed (for chats).
parent
1a820d39
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
StringUtils.java
app/src/main/java/com/xabber/android/utils/StringUtils.java
+18
-7
No files found.
app/src/main/java/com/xabber/android/utils/StringUtils.java
View file @
bca36b8c
...
...
@@ -14,10 +14,13 @@
*/
package
com
.
xabber
.
android
.
utils
;
import
android.content.res.Resources
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
android.content.res.Resources
;
import
java.util.GregorianCalendar
;
/**
* Helper class to get plural forms.
...
...
@@ -32,7 +35,7 @@ public class StringUtils {
static
{
DATE_TIME
=
DateFormat
.
getDateTimeInstance
(
DateFormat
.
MEDIUM
,
DateFormat
.
SHORT
);
TIME
=
DateFormat
.
getTimeInstance
(
DateFormat
.
MEDIUM
);
TIME
=
new
SimpleDateFormat
(
"H:mm"
);
}
private
StringUtils
()
{
...
...
@@ -121,11 +124,19 @@ public class StringUtils {
* @return String with time or with date and time depend on current time.
*/
public
static
String
getSmartTimeText
(
Date
timeStamp
)
{
if
(
timeStamp
==
null
)
if
(
timeStamp
==
null
)
{
return
""
;
Date
date
=
new
Date
();
long
delta
=
date
.
getTime
()
-
timeStamp
.
getTime
();
if
(
delta
<
20
*
60
*
60
*
1000
)
}
// today
Calendar
midnight
=
new
GregorianCalendar
();
// reset hour, minutes, seconds and millis
midnight
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
midnight
.
set
(
Calendar
.
MINUTE
,
0
);
midnight
.
set
(
Calendar
.
SECOND
,
0
);
midnight
.
set
(
Calendar
.
MILLISECOND
,
0
);
if
(
timeStamp
.
getTime
()
>
midnight
.
getTimeInMillis
())
synchronized
(
TIME
)
{
return
TIME
.
format
(
timeStamp
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment