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
52b38829
Commit
52b38829
authored
Feb 27, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chat message: only time (not date) is show for today's messages.
parent
0404898d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
StringUtils.java
app/src/main/java/com/xabber/android/utils/StringUtils.java
+18
-2
No files found.
app/src/main/java/com/xabber/android/utils/StringUtils.java
View file @
52b38829
...
...
@@ -19,7 +19,9 @@ import android.content.res.Resources;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.GregorianCalendar
;
/**
* Helper class to get plural forms.
...
...
@@ -127,10 +129,24 @@ public class StringUtils {
return
""
;
}
// 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
);
DateFormat
timeFormat
=
android
.
text
.
format
.
DateFormat
.
getTimeFormat
(
context
);
DateFormat
dateFormat
=
android
.
text
.
format
.
DateFormat
.
getDateFormat
(
context
);
return
dateFormat
.
format
(
timeStamp
)
+
" "
+
timeFormat
.
format
(
timeStamp
);
if
(
timeStamp
.
getTime
()
>
midnight
.
getTimeInMillis
())
{
synchronized
(
TIME
)
{
return
timeFormat
.
format
(
timeStamp
);
}
}
else
{
DateFormat
dateFormat
=
android
.
text
.
format
.
DateFormat
.
getDateFormat
(
context
);
return
dateFormat
.
format
(
timeStamp
)
+
" "
+
timeFormat
.
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