Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-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
AloqaIM-Android
Commits
75cec1b3
Commit
75cec1b3
authored
Jan 17, 2017
by
Tiago Cunha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using the best pattern for locale when available
parent
57e4826a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
6 deletions
+31
-6
DateTime.java
app/src/main/java/chat/rocket/android/helper/DateTime.java
+31
-6
No files found.
app/src/main/java/chat/rocket/android/helper/DateTime.java
View file @
75cec1b3
package
chat
.
rocket
.
android
.
helper
;
import
android.os.Build
;
import
android.text.format.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.GregorianCalendar
;
import
java.util.Locale
;
import
java.util.TimeZone
;
import
chat.rocket.android.log.RCLog
;
...
...
@@ -11,13 +15,34 @@ import chat.rocket.android.log.RCLog;
* Utility class for converting epoch ms and date-time string.
*/
public
class
DateTime
{
private
static
final
String
TAG
=
DateTime
.
class
.
getName
();
private
static
final
String
TAG
=
"DateTime"
;
private
static
final
SimpleDateFormat
TIME_FORMAT
;
private
static
final
SimpleDateFormat
DATE_FORMAT
;
private
static
final
SimpleDateFormat
DAY_FORMAT
;
private
static
final
SimpleDateFormat
DAY_TIME_FORMAT
;
private
static
final
SimpleDateFormat
DATE_TIME_FORMAT
;
static
{
Locale
locale
=
Locale
.
getDefault
();
private
static
final
SimpleDateFormat
TIME_FORMAT
=
new
SimpleDateFormat
(
"HH:mm"
);
private
static
final
SimpleDateFormat
DATE_FORMAT
=
new
SimpleDateFormat
(
"yyyy/MM/dd"
);
private
static
final
SimpleDateFormat
DAY_FORMAT
=
new
SimpleDateFormat
(
"MM/dd"
);
private
static
final
SimpleDateFormat
DAY_TIME_FORMAT
=
new
SimpleDateFormat
(
"MM/dd HH:mm"
);
private
static
final
SimpleDateFormat
DATE_TIME_FORMAT
=
new
SimpleDateFormat
(
"yyyy/MM/dd HH:mm"
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR2
)
{
TIME_FORMAT
=
new
SimpleDateFormat
(
DateFormat
.
getBestDateTimePattern
(
locale
,
"HHmm"
),
locale
);
DATE_FORMAT
=
new
SimpleDateFormat
(
DateFormat
.
getBestDateTimePattern
(
locale
,
"yyyyMMdd"
),
locale
);
DAY_FORMAT
=
new
SimpleDateFormat
(
DateFormat
.
getBestDateTimePattern
(
locale
,
"MMdd"
),
locale
);
DAY_TIME_FORMAT
=
new
SimpleDateFormat
(
DateFormat
.
getBestDateTimePattern
(
locale
,
"MMddHHmm"
),
locale
);
DATE_TIME_FORMAT
=
new
SimpleDateFormat
(
DateFormat
.
getBestDateTimePattern
(
locale
,
"yyyyMMddHHmm"
),
locale
);
}
else
{
TIME_FORMAT
=
new
SimpleDateFormat
(
"HH:mm"
,
locale
);
DATE_FORMAT
=
new
SimpleDateFormat
(
"yyyy/MM/dd"
,
locale
);
DAY_FORMAT
=
new
SimpleDateFormat
(
"MM/dd"
,
locale
);
DAY_TIME_FORMAT
=
new
SimpleDateFormat
(
"MM/dd HH:mm"
,
locale
);
DATE_TIME_FORMAT
=
new
SimpleDateFormat
(
"yyyy/MM/dd HH:mm"
,
locale
);
}
}
/**
* convert datetime ms to String.
...
...
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