我只想让日期显示如下:
Saturday, May 26, 2012 at 10:42 PM
到目前为止,这是我的代码:
Calendar calendar = Calendar.getInstance();
String theDate = calendar.get(Calendar.MONTH) + " " + calendar.get(Calendar.DAY_OF_MONTH) + " " + calendar.get(Calendar.YEAR);
lastclick.setText(getString(R.string.lastclick) + " " + theDate);
Run Code Online (Sandbox Code Playgroud)
这显示了月,日和年的数字,但必须有更好的方法吗?是不是有一些简单的方法来做这个就像使用PHP的date()
功能?
无论出于何种原因,尽管此代码确实刷新了页面,但没有字段被发布...
$('form').submit(function(){
$('input[type=submit]', this).attr('disabled', 'disabled');
});
Run Code Online (Sandbox Code Playgroud)
有没有更好的编码方式?
继承我的代码:
$sql = mysql_query("select c.name, c.address, c.postcode, c.dob, c.mobile, c.email,
count(select * from bookings where b.id_customer = c.id) as purchased, count(select * from bookings where b.the_date > $now) as remaining,
from customers as c, bookings as b
where b.id_customer = c.id
order by c.name asc");
Run Code Online (Sandbox Code Playgroud)
你可以看到我想要做什么,但我不知道如何正确编写这个查询.
继承人得到的错误:
警告:mysql_fetch_assoc():提供的参数不是有效的MySQL结果资源
继承我的mysql_fetch_assoc:
<?php
while ($row = mysql_fetch_assoc($sql))
{
?>
<tr>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['mobile']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['purchased']; ?></td>
<td><?php echo $row['remaining']; ?></td>
</tr>
<?php
} …
Run Code Online (Sandbox Code Playgroud) 我正在尝试以下列格式输出我的代码:
january 2012 - 34
february 2012 - 23
Run Code Online (Sandbox Code Playgroud)
其中34和23将是该月内具有id_dealership为7的总行数.我需要此输出所有已完成作业的月份的所有数据.
该assignments
表结构如下:
id_dealer (int)
date_assigned (int)
Run Code Online (Sandbox Code Playgroud)
我试过了,但它根本不起作用:
SELECT MONTH(date_assigned), YEAR(date_assigned), COUNT(*)
FROM assignments
GROUP BY MONTH(date_assigned), YEAR(date_assigned)
Run Code Online (Sandbox Code Playgroud) 试图获取a的值,cookie
如果它的值设置并div
用cookie
值更新a ,否则生成80-100之间的随机数,设置为cookie
,然后更新div
.
我得到错误:
Object function (a,b){return new e.fn.init(a,b,h)} has no method 'cookie'
Run Code Online (Sandbox Code Playgroud)
继承我的代码:
$(document).ready(function(){
var thecounter = '';
if ($.cookie('thecounter') == null)
{
thecounter = $.randomBetween(80, 100);
$.cookie('thecounter', thecounter, { path: '/' });
}
else
{
thecounter = $.cookie('thecounter');
}
$('dd-counter-num').html(thecounter);
setTimeout(newtime, 5000);
});
function newtime () {
var newtime = $.cookie('thecounter') + $.randomBetween(1, 2);
$.cookie('thecounter', newtime, { path: '/' });
$('dd-counter-num').html(newtime);
setTimeout(newtime, 5000);
}
Run Code Online (Sandbox Code Playgroud) 在我的数据库中,我有几个"真实"字段.
继承人的结构:
database.execSQL("create table " + TABLE_LOGS + " ("
+ COLUMN_ID + " integer primary key autoincrement,"
+ COLUMN_ID_DAY_EXERCISE + " integer not null,"
+ COLUMN_REPS + " integer not null"
+ COLUMN_WEIGHT + " real not null"
+ COLUMN_1RM + " real not null"
+ COLUMN_DATE + " integer not null"
+ ")");
Run Code Online (Sandbox Code Playgroud)
现在我要做的是计算1RM,以便我可以将它插入数据库.
到目前为止,这是我的功能:
public void createLog(long id_day_exercise, float reps, long weight) {
// create 1rm
// create date timestamp
float onerm = weight/(1.0278-(.0278*reps));
long unixTime = …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个输出这个的循环:
08:00
08:15
08:30
08:45
09:00
09:15
09:30
09:45
Run Code Online (Sandbox Code Playgroud)
我需要它从08:00到17:00
到目前为止我的代码:
function echo_datelist ($i, $j, $day, $month, $year)
{
$time = str_pad($i, 2, '0', STR_PAD_LEFT).':'.str_pad($j, 2, '0', STR_PAD_LEFT);
$date = strtotime("$month $day $year $time:00");
$sql = mysql_query("select b.room_type, c.name from bookings as b, customers as c where b.the_date='$date' and b.id_customer=c.id");
echo $time.'<br />';
}
for ($i = 8; $i <= 16; $i++)
{
for ($j = 0; $j <= 45; $j+=15)
echo_datelist($i, $j, $day, $month, $year);
echo_datelist(17, 0, $day, $month, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试让ImageView在我的drawable文件夹中的2个图像之间进行动画处理.
我认为一切都会正常,但日志显示错误: Only the original thread that created a view hierarchy can touch its views.
继承我的代码:
public class ExerciseActivity extends Activity {
private ExercisesDataSource datasource;
private Cursor cursor;
private ImageView image_1_view;
private Timer _timer;
private int _index;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_exercise);
datasource = new ExercisesDataSource(this);
datasource.open();
cursor = datasource.fetchExercise(exerciseDataID);
image_1_view = (ImageView) findViewById(R.id.exercise_image);
_index = 1;
_timer = new Timer();
_timer.schedule(new TickClass(), 1000);
}
public class TickClass extends TimerTask
{
private int columnIndex;
@Override
public void …
Run Code Online (Sandbox Code Playgroud) 我有一个包含以下字段的表:
我正在尝试创建一个查询,该查询将按一年中的每个星期对所有销售进行分组,然后在我的页面上拆分每周的amount_sales总和.
例:
week 1 = $26.00
week 2 = $35.00
week 3 = $49.00
Run Code Online (Sandbox Code Playgroud)
我正在使用此查询,但它不起作用:
SELECT SUM(`amount_sale`) as total
FROM `sales`
WHERE `payment_type` = 'Account'
GROUP BY WEEK(`the_date`)
Run Code Online (Sandbox Code Playgroud) 我在尝试将大型CSV文件导入localhost上的mysql时遇到了麻烦.
CSV大约为55 MB,大约有750,000行.
我重写了脚本,以便它解析CSV并逐个转储行.
这是代码:
$row = 1;
if (($handle = fopen("postal_codes.csv", "r")) !== FALSE)
{
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
$num = count($data);
$row++;
for ($c=0; $c < $num; $c++)
{
$arr = explode('|', $data[$c]);
$postcode = mysql_real_escape_string($arr[1]);
$city_name = mysql_real_escape_string($arr[2]);
$city_slug = mysql_real_escape_string(toAscii($city_name));
$prov_name = mysql_real_escape_string($arr[3]);
$prov_slug = mysql_real_escape_string(toAscii($prov_name));
$prov_abbr = mysql_real_escape_string($arr[4]);
$lat = mysql_real_escape_string($arr[6]);
$lng = mysql_real_escape_string($arr[7]);
mysql_query("insert into cities (`postcode`, `city_name`, `city_slug`, `prov_name`, `prov_slug`, `prov_abbr`, `lat`, `lng`)
values ('$postcode', '$city_name', '$city_slug', '$prov_name', …
Run Code Online (Sandbox Code Playgroud)