UserAndroid Posted February 20, 2012 Share Posted February 20, 2012 Comment insérer une date dans une table (Sqlite) ? Link to comment Share on other sites More sharing options...
chpil Posted February 21, 2012 Share Posted February 21, 2012 peut-être en faisant une requête sql d'insertion... Quel est ton problème ? Qu'est-ce que tu ne sais pas faire ? Tu peux être plus précis ? Link to comment Share on other sites More sharing options...
grabeuh Posted February 21, 2012 Share Posted February 21, 2012 Il n'y a pas de champ date en Sqlite. On peut insérer la date un peu comme on veut. J'ai opté pour le long en millisecondes : int year = 2012; int month = 11; int day = 25; GregorianCalendar cal = new GregorianCalendar(year, month, day); long date = cal.getTime().getTime(); Et pour relire, on fait l'opération inverse : // Lire date (long) depuis la base int day, year, month; GregorianCalendar cal = new GregorianCalendar(); cal.setTimeInMillis(date); day = cal.get(GregorianCalendar.DAY_OF_MONTH); month = cal.get(GregorianCalendar.MONTH); year = cal.get(GregorianCalendar.YEAR); On peut aussi stocker la date en texte et utiliser les fonctions Sqlite pour la relire correctement. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.