1111import android .support .v4 .app .NotificationCompat ;
1212import android .util .Log ;
1313
14+ import java .text .ParseException ;
15+ import java .text .SimpleDateFormat ;
1416import java .util .Calendar ;
17+ import java .util .Date ;
1518
1619import info .papdt .express .helper .R ;
1720import info .papdt .express .helper .dao .PackageDatabase ;
@@ -77,7 +80,7 @@ private static int parseDefaults(Context context) {
7780 }
7881
7982 @ SuppressWarnings ("getNotification" )
80- private static Notification buildNotification (Context context , String title , String subject , String longText , String time , int icon , int color ,
83+ private static Notification buildNotification (Context context , String title , String subject , String longText , long time , int icon , int color ,
8184 int defaults , PendingIntent contentIntent , PendingIntent deleteIntent ) {
8285 Notification n ;
8386 NotificationCompat .Builder builder = new NotificationCompat .Builder (context );
@@ -88,7 +91,7 @@ private static Notification buildNotification(Context context, String title, Str
8891 builder .setDefaults (defaults );
8992 builder .setSmallIcon (icon );
9093 builder .setContentIntent (contentIntent );
91- builder .setSubText (time );
94+ builder .setWhen (time );
9295 builder .setAutoCancel (true );
9396
9497 if (Build .VERSION .SDK_INT >= 21 ) {
@@ -135,11 +138,21 @@ private Notification produceNotifications(int position, Package exp) {
135138 smallIcon = R .drawable .ic_assignment_returned_white_24dp ;
136139 }
137140
141+ String myDate = exp .data .get (0 ).time ;
142+ SimpleDateFormat sdf = new SimpleDateFormat ("yyyy/MM/dd HH:mm:ss" );
143+ long millis = 0 ;
144+ try {
145+ Date date = sdf .parse (myDate );
146+ millis = date .getTime ();
147+ } catch (ParseException e ) {
148+ e .printStackTrace ();
149+ }
150+
138151 Notification n = buildNotification (getApplicationContext (),
139152 title ,
140153 subject ,
141154 exp .data .get (0 ).context ,
142- exp . data . get ( 0 ). time ,
155+ millis ,
143156 smallIcon ,
144157 getResources ().getIntArray (R .array .statusColor ) [exp .getState ()],
145158 defaults ,
0 commit comments